Announcement Announcement Module
Collapse
No announcement yet.
Why doesn't rollback? (doesn't work TransactionProxyFactor) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    I guess..

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

    Comment


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

      Comment


      • #4
        yes

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

        Comment


        • #5
          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

          Comment

          Working...
          X