Announcement Announcement Module
Collapse
No announcement yet.
HibernateTransactionManager doesn't work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    First of all, I don't think you should have added +HibernateException to your properties - this exception is a RuntimeException and the transaction roll-backs by default in case this one is thrown.
    Second,
    A "+" before an exception name substring indicates that transactions should commit even if this exception is thrown; a "-" that they should roll back.
    from http://www.springframework.org/docs/...uteEditor.html
    so, it should have been with a "-".

    Try removing the +HibernateException from your attributes and test again.

    Comment


    • #17
      First I've change HibernateException with '-' and then I've deleted this exception from configuration file and still it doesn't work correctly.

      I'm wondering why in debug file I have:
      Code:
      Winning rollback rule is: null
      and then transaction is commited.

      Maybe there is a problem.

      Comment


      • #18
        OK, everything works fine with hibernate transaction manager.

        Now I have another problem, because I need to change Hibernate Transaction Manager to JTA Transaction Manager.

        Can somebody tell me what I have to change in my configuration?

        Comment


        • #19
          What was the problem with Hibernate transaction manager roll-back ?

          Comment


          • #20
            Originally posted by martique View Post
            OK, everything works fine with hibernate transaction manager.
            I'm not quite sure I understand this, weren't you original using the HibernateTransactionManager?
            Last edited by karldmoore; Aug 29th, 2007, 12:14 PM.

            Comment


            • #21
              Yes, I was.

              It was temporary solution to see if transactions are working in my application.
              Now I have to use JTA transaction manager and it's not working

              Comment


              • #22
                Could you posted the updated parts of the configuration, along with the DEBUG logging?
                Last edited by karldmoore; Aug 29th, 2007, 12:14 PM.

                Comment


                • #23
                  My configuration for JTA transaction look like this:

                  Code:
                  	<bean id="userFacade" class="org.bivela.business.facade.UserFacade">
                  		<property name="sessionFactory"><ref bean="userSessionFactory" /></property>
                  	</bean>
                  
                          <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">		
                  	</bean>		
                  	<bean id="jtaTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
                  		<property name="transactionManager"><ref local="jtaTransactionManager" /></property>	
                  		<property name="transactionAttributeSource">
                  			<value>				org.bivela.business.facade.UserFacadeInterface.updateShareholders=PROPAGATION_REQUIRED
                  			</value>
                  		</property>
                  	</bean>
                  
                  	<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
                  		<property name="sessionFactory"><ref bean="userSessionFactory" /></property>
                  	</bean>
                  	 
                  	<bean id="userProxyService" class="org.springframework.aop.framework.ProxyFactoryBean">
                  		<property name="proxyInterfaces">
                  			<value>org.bivela.business.facade.UserFacadeInterface</value>
                  		</property>
                  		<property name="target" ref="userFacade" />
                  		<property name="interceptorNames">
                  			<list>							
                  				<!-- <value>hibernateInterceptor</value> -->
                  				<value>jtaTransactionInterceptor</value>				
                  			</list>
                  		</property>
                  	</bean>
                  
                  	<bean id="userDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
                  			<property name="driverClassName">
                  				<value>${db.driver}</value>
                  			</property>
                  			<property name="url">
                  				<value>${db.url}</value>
                  			</property>
                  			<property name="username">
                  				<value>${user.name}</value>
                  			</property>
                  			<property name="password">
                  				<value>${user.password}</value>
                  			</property>
                  			
                  			 
                  			<property name="maxActive">
                  				<value>15</value>
                  			</property>
                  	 	</bean> 
                  
                  
                  		<property name="jtaTransactionManager">
                  			<bean id="jtaTransactionManager.transactionManager" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
                  		</property>
                  		
                  		<property name="hibernateProperties">
                  			<props>						
                  				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
                  				<prop key="hibernate.show_sql">true</prop>
                  				<prop key="hibernate.current_session_context_class">thread</prop>
                  				<prop key="hibernate.max_fetch_depth">3</prop>
                  				
                  				<prop key="hibernate.connection.pool_size">3</prop>
                  				<prop key="hibernate.connection.isolation">2</prop>
                  				<prop key="hibernate.connection.release_mode">after_transaction</prop>
                  				<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
                  				<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
                  								
                  				<prop key="hibernate.hbm2dll.auto">create</prop>
                             						
                  				<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>	
                  			</props>
                  		</property>
                  	</bean>
                  and debug file:

                  Code:
                  2007-07-03 10:01:40,024 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@2f0e07]
                  2007-07-03 10:01:40,024 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Creating new transaction with name [org.bivela.business.facade.UserFacadeInterface.updateShareholders]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
                  2007-07-03 10:01:40,024 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Initializing transaction synchronization
                  2007-07-03 10:01:40,026 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Getting transaction for [org.bivela.business.facade.UserFacadeInterface.updateShareholders]
                  2007-07-03 10:01:40,026 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Opening Hibernate Session
                  2007-07-03 10:01:40,033 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
                  2007-07-03 10:01:40,033 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 11834497000
                  2007-07-03 10:01:40,033 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Registering Spring transaction synchronization for new Hibernate Session
                  2007-07-03 10:01:40,043 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Bound value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] to thread [http-0.0.0.0-8443-3]
                  2007-07-03 10:01:40,044 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
                  2007-07-03 10:01:40,045 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Found thread-bound Session for HibernateTemplate
                  2007-07-03 10:01:40,045 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
                  2007-07-03 10:01:40,046 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
                  2007-07-03 10:01:40,046 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
                  2007-07-03 10:01:40,046 DEBUG [org.hibernate.SQL] select companies0_.id as id5_, companies0_.name as name5_, 
                  
                  ....
                  
                  2007-07-03 10:01:40,052 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
                  2007-07-03 10:01:40,052 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Retrieved value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] bound to thread [http-0.0.0.0-8443-3]
                  2007-07-03 10:01:40,053 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Found thread-bound Session for HibernateTemplate
                  2007-07-03 10:01:40,053 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] parse() - HQL: select share from org.bivela.dto.bivela.Shareholders share JOIN FETCH share.company company WHERE company.id = ?
                  
                  ...
                  
                  2007-07-03 10:01:40,226 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
                  2007-07-03 10:01:40,226 DEBUG [org.springframework.orm.hibernate3.HibernateTemplate] Not closing pre-bound Hibernate Session after HibernateTemplate
                  2007-07-03 10:01:40,226 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Completing transaction for [org.bivela.business.facade.UserFacadeInterface.updateShareholders] after exception: org.hibernate.HibernateException: Blad wymuszony
                  2007-07-03 10:01:40,226 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] Applying rules to determine whether transaction should rollback on org.hibernate.HibernateException: Blad wymuszony
                  2007-07-03 10:01:40,227 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] Winning rollback rule is: null
                  2007-07-03 10:01:40,227 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] No relevant rollback rule found: applying superclass default
                  2007-07-03 10:01:40,227 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Triggering beforeCompletion synchronization
                  2007-07-03 10:01:40,234 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Removed value [org.springframework.orm.hibernate3.SessionHolder@16a90c9] for key [org.hibernate.impl.SessionFactoryImpl@1479784] from thread [http-0.0.0.0-8443-3]
                  2007-07-03 10:01:40,234 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Closing Hibernate Session
                  2007-07-03 10:01:40,234 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
                  2007-07-03 10:01:40,236 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Initiating transaction rollback
                  2007-07-03 10:01:40,236 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
                  2007-07-03 10:01:40,236 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Triggering afterCompletion synchronization
                  2007-07-03 10:01:40,236 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization
                  2007-07-03 10:01:40,236 DEBUG [org.springframework.web.servlet.DispatcherServlet] Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@13214d1
                  2007-07-03 10:01:40,237 DEBUG [org.springframework.web.servlet.DispatcherServlet] Could not complete request
                  org.hibernate.HibernateException: Blad wymuszony
                  	at org.bivela.business.facade.UserFacade.updateShareholders(UserFacade.java:1377)
                  I use JBoss and MySQL servers.
                  Last edited by martique; Jul 3rd, 2007, 04:15 AM.

                  Comment


                  • #24
                    I've noticed that when I'm using jta transaction manager, hibernate session is closed before transaction rollback action.

                    So, can somebody help me with this configuration, please?

                    Comment

                    Working...
                    X