Results 1 to 5 of 5

Thread: Why doesn't rollback? (doesn't work TransactionProxyFactor)

  1. #1
    Join Date
    Nov 2004
    Posts
    3

    Default Why doesn't rollback? (doesn't work TransactionProxyFactor)

    I have a question... I want to use transaction in environment of Mysql & resin. so I was using Spring Framwork at this.

    applicationContex.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    	<!-- ========================= GENERAL DEFINITIONS ========================= -->
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
    		<property name="contentType"><value>EUC-KR</value></property>
        </bean>
    
    	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename"><value>/WEB-INF/messages</value></property>
    		<property name="defaultEncoding"><value>EUC-KR</value></property>
    		<property name="cacheSeconds"><value>0</value></property>
        </bean>
    
    	<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
    
    	<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->
    	<!-- transactionTest primary business object&#58; default implementation -->
    	<bean id="userManager" class="net.playforum.transaction.domain.logic.UserManager">
    		<property name="userDao"><ref bean="userDao"/></property>
    	</bean>
    	
    	<!-- Transactional proxy for the transactionTest primary business object -->
    	<bean id="testTransaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref bean="transactionManager"/></property>
    		<property name="target"><ref local="userManager"/></property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
    			</props>
    		</property>
    	</bean>
    </beans>
    dataAccessContext-local.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    	
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName"><value>java&#58;comp/env/jdbc/test</value></property>
    	</bean>
    
    	
    	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        	<property name="dataSource"><ref local="dataSource"/></property>
    		<property name="rollbackOnCommitFailure"><value>true</value></property>
    	</bean>
    
    	<bean id="userDao" class="test.transaction.domain.logic.UserDao">
    		<property name="dataSource"> <ref local="dataSource"/> </property>
    		<property name="updateDataSource"> <ref local="dataSource"/></property>
    	</bean>
    		
    </beans>
    UserManager.java
    Code:
    public class UserManager &#123;
      .
      .
        public boolean  updatePoint&#40; String sender,   String receiver,  int amount&#41; &#123;
            boolean result = false;
           
            if &#40; checkPoint&#40;sender, amount&#41; &#41;&#123;
                            this.userDao.updatePoint&#40;sender, amount * -1&#41;;
                            this.userDao.updatePoint&#40;receiver, amount&#41;;
                            result = true;
            &#125;
    		return result;
        &#125;
     .
     .
     .
    &#125;
    but doesn't work transactionaly....;; What is problem?
    Who is can help...me??

  2. #2
    Join Date
    Nov 2004
    Posts
    3

    Default I guess..

    I guess..aop dos not work... so transaction does not work...

  3. #3
    Join Date
    Aug 2004
    Location
    Toronto
    Posts
    8

    Default

    An obvious question perhaps, but i'll ask anyway. Are you using transactional tables in MySQL?

  4. #4
    Join Date
    Nov 2004
    Posts
    3

    Default yes

    yes... I was create table to innodb..

  5. #5
    Join Date
    Sep 2004
    Location
    Winterthur, Switzerland
    Posts
    58

    Default

    Question: how are you testing this?
    Be aware that the bean "testTransaction" is a proxy to the bean "userManager", so all method invocations on "userManager" need to go through "testTransaction". So eventually check where "userManager" is refered and possibly change to "testTransaction".
    Christoph

Similar Threads

  1. Replies: 3
    Last Post: Mar 1st, 2010, 05:45 PM
  2. Programmatically rollback a declarative transaction
    By george in forum Architecture
    Replies: 10
    Last Post: Jun 15th, 2007, 01:39 PM
  3. Replies: 1
    Last Post: Jun 23rd, 2005, 02:13 AM
  4. Replies: 0
    Last Post: Jun 6th, 2005, 06:22 AM
  5. Need help on JDBC Rollback..
    By Intruder in forum Data
    Replies: 1
    Last Post: Dec 21st, 2004, 02:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •