Results 1 to 7 of 7

Thread: Transaction Rollback But Not Hibernate

  1. #1
    Join Date
    Mar 2005
    Location
    Toronto, Canada
    Posts
    6

    Default Transaction Rollback But Not Hibernate

    I was trying to test my global transaction setup by purposely causing an unchecked "MissingResourceException", during the invocation of the method "addGeneralUser" in "userFacade" from the web-layer (see below), even though, the transaction was rolled back (see the debugging message below), Hibernate still wrote the data to mySQL (I use InnoDB). I am using Spring v2.0.3, Hibernate v3.2.2 running in Tomcat v5.5.17 with mySQL v5.0.27.

    public Response addGeneralUser(User user, Role role) throws Exception {
    logger.info("About to execute addUser...");
    if (userDAO.loadUserByUsername(user.getEmailAddress() ) == null) {
    user.setStatus(User.UserStatus.CREATED);
    user.getRoles().add(role);
    }
    else {
    String[] params = {user.getEmailAddress()};
    return new Response(new Status(false, "msg_user_already_exists", params,
    origin, "User with " + user.getEmailAddress() + " already exists."));
    }

    logger.info("user:" + user);
    userDAO.saveObject(user);

    long[] ids = {user.getId()};

    ResourceBundle configurations = ResourceBundle.getBundle("app_config");
    ...

    See rollback_msg.txt attached for the debugging messages generated when it was trying to rollback after the exception was thrown:

    See spring_config.txt attached for my Spring configurations.

    In the debugging messages displayed below, I noticed that Hibernate was using "direct JDBC transactions".

    2007-04-16 14:32:55,224 INFO [org.hibernate.transaction.TransactionFactoryFactor y] - Using default transaction strategy (direct JDBC transactions)
    2007-04-16 14:32:55,234 INFO [org.hibernate.transaction.TransactionManagerLookup Factory] - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    2007-04-16 14:32:55,234 INFO [org.hibernate.cfg.SettingsFactory] - Automatic flush during beforeCompletion(): disabled
    2007-04-16 14:32:55,234 INFO [org.hibernate.cfg.SettingsFactory] - Automatic session close at end of transaction: disabled
    2007-04-16 14:32:55,234 INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch size: 15
    2007-04-16 14:32:55,234 INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch updates for versioned data: disabled

    The following is some of the debugging messages when the transaction started:

    2007-04-16 14:36:13,975 INFO [com.p2ka.teeoff.ui.page.admin.AddUserPage] - about to execute addUser()...user: User: BaseObject: id [0] version [0] createdDate [Mon Apr 16 14:36:13 EDT 2007] createdBy [a@b.com] lastUpdatedDate [Mon Apr 16 14:36:13 EDT 2007] lastUpdatedBy [a@b.com] firstName [M] lastName [M] emailAddress [m@m.com] addressLine1 [null] addressLine2 [null] city [null] province [null] country [null] postalCode [null] phoneNumber [4165550013] username [m@m.com] password [123456] secretQuestion [null] secretAnswer [null] enabled [UNKNOWN] willingToReceiveEmail [true] handicap [0] roles [0]
    2007-04-16 14:36:13,995 DEBUG [org.springframework.transaction.jta.JtaTransaction Manager] - Using transaction object [org.springframework.transaction.jta.JtaTransaction Object@7ac6c]
    2007-04-16 14:36:13,995 DEBUG [org.objectweb.jotm.jta] - Current.getStatus()
    2007-04-16 14:36:13,995 DEBUG [org.objectweb.jotm.jta] - threadTx.get= java.lang.ThreadLocal@1c8f3cd
    2007-04-16 14:36:13,995 DEBUG [org.objectweb.jotm.jta] - Transaction ret= null
    2007-04-16 14:36:13,995 DEBUG [org.springframework.transaction.jta.JtaTransaction Manager] - Creating new transaction with name [UserFacade.addGeneralUser]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
    2007-04-16 14:36:13,995 DEBUG [org.objectweb.jotm.jta] - begin transaction
    2007-04-16 14:36:13,995 DEBUG [org.objectweb.jotm.jta] - threadTx.get= java.lang.ThreadLocal@1c8f3cd
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - xid= bb14:38:0:010198190160db754d...14d401:
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - timeout= 60
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - xid=bb14:38:0:010198190160db754d...14d401:, timeout=60
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - tx=bb14:38:0:010198190160db754d...14d401:
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - TransactionImpl.doAttach flag= TMJOIN
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - number of enlisted= 0
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - threadTx.set= java.lang.ThreadLocal@1c8f3cd
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - Associate tx to xid (xid=bb14:38:0:010198190160db754d...14d401
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - TimerEvent.new(bb14:38:0:010198190160db754d...14d4 01:,60,null,false)
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - set timer for tx (timer=org.objectweb.jotm.TimerEvent@85097d, tx=bb14:38:0:010198190160db754d...14d401
    2007-04-16 14:36:14,015 DEBUG [org.objectweb.jotm.jta] - set date for tx (data=Mon Apr 16 14:36:14 EDT 2007, tx=bb14:38:0:010198190160db754d...14d401
    2007-04-16 14:36:14,015 DEBUG [org.springframework.transaction.support.Transactio nSynchronizationManager] - Initializing transaction synchronization
    2007-04-16 14:36:14,025 DEBUG [org.springframework.transaction.interceptor.Transa ctionInterceptor] - Getting transaction for [com.p2ka.teeoff.service.user.UserFacade.addGeneral User]


    I wonder if this caused Hibernate not to use any transaction. If so, how can I fix the problem. If not, any pointer that can help me figuring out the problem. Thanks in advance.
    Attached Files Attached Files

  2. #2

    Default

    My work firewall doesn't allow me to see attachments but I would suggest for you to double check your spring context configuration. I think hibernate doesn't know about spring managed transactions. Judging from the log you are using Jta Manager so Hibernate should have setup that will look like this:

    Code:
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource"><ref bean="dataSource"/></property>
    		<property name="configLocation">
    			<value>classpath:hibernate.cfg.xml</value>
    		</property>
    		<property name="entityInterceptor">
    			<ref local="hibernateInterceptor"/>
    		</property>
    		<property name="useTransactionAwareDataSource">
    			<value>true</value>
    		</property>		
    		<property name="hibernateProperties">
    			<props>
    			    <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
    				<prop key="hibernate.show_sql">false</prop>
    				<prop key="hibernate.connection.release_mode">after_transaction</prop>
    			</props>
    		</property>
    		<property name="jtaTransactionManager">
    			<bean id="transactionManager.transactionManager" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    		</property>
    	</bean>
    
    	<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
    Hope this helps.

    Vitaliy

  3. #3
    Join Date
    Mar 2005
    Location
    The Netherlands
    Posts
    121

    Default

    Adding the following Hibernate property to your LocalSessionFactoryBean will help:

    <prop key="hibernate.transaction.factory_class">org.hibe rnate.transaction.JTATransactionFactory</prop>

    BTW, why are you using JOTM and JTA? Wouldn't Spring's HibernateTransactionManager suffice?

    Joris

  4. #4
    Join Date
    Mar 2005
    Location
    Toronto, Canada
    Posts
    6

    Default Hibernate Still Not Rolling Back

    I added "<property name="jtaTransactionManager"><bean id="transactionManager.transactionManager" class="org.springframework.beans.factory.config.Pr opertyPathFactoryBean"/>
    </property>", and the "direct JDBC transaction" was no longer there (see below)

    <code>
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Creating shared instance of singleton bean 'sessionFactory'
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Creating instance of bean 'sessionFactory' with merged definition [Root bean: class [org.springframework.orm.hibernate3.LocalSessionFac toryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/applicationContext.xml]]
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Eagerly caching bean 'sessionFactory' to allow for resolving potential circular references
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Returning cached instance of singleton bean 'dataSource'
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Creating instance of bean 'transactionManager.transactionManager' with merged definition [Root bean: class [org.springframework.beans.factory.config.PropertyP athFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/applicationContext.xml]]
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Creating shared instance of singleton bean 'transactionManager'
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Creating instance of bean 'transactionManager' with merged definition [Root bean: class [org.springframework.transaction.jta.JtaTransaction Manager]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in ServletContext resource [/WEB-INF/applicationContext.xml]]
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Eagerly caching bean 'transactionManager' to allow for resolving potential circular references
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Returning cached instance of singleton bean 'jotm'
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Invoking afterPropertiesSet() on bean with name 'transactionManager'
    [org.springframework.transaction.jta.JtaTransaction Manager] - JTA UserTransaction object [org.objectweb.jotm.Current@1087d61] implements TransactionManager
    [org.springframework.transaction.jta.JtaTransaction Manager] - Using JTA UserTransaction: org.objectweb.jotm.Current@1087d61
    [org.springframework.transaction.jta.JtaTransaction Manager] - Using JTA TransactionManager: org.objectweb.jotm.Current@1087d61
    [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Invoking afterPropertiesSet() on bean with name 'sessionFactory'
    ...
    [org.hibernate.transaction.TransactionFactoryFactor y] - Transaction strategy: org.hibernate.transaction.JTATransactionFactory
    [org.hibernate.util.NamingHelper] - JNDI InitialContext properties:{}
    [org.hibernate.transaction.TransactionManagerLookup Factory] - instantiating TransactionManagerLookup: org.springframework.orm.hibernate3.LocalTransactio nManagerLookup
    [org.hibernate.transaction.TransactionManagerLookup Factory] - instantiated TransactionManagerLookup
    [org.hibernate.transaction.TransactionManagerLookup Factory] - instantiating TransactionManagerLookup: org.springframework.orm.hibernate3.LocalTransactio nManagerLookup
    [org.hibernate.transaction.TransactionManagerLookup Factory] - instantiated TransactionManagerLookup
    [org.hibernate.cfg.SettingsFactory] - Automatic flush during beforeCompletion(): disabled
    [org.hibernate.cfg.SettingsFactory] - Automatic session close at end of transaction: disabled
    </code>

    The transaction was rolled back (see messages below) the same way as the first time, however, Hibernate still didn't rollback for whatever reason:

    <code>
    INFO [BaseDAOImpl] - about to execute saveObject()...
    [org.springframework.transaction.support.Transactio nSynchronizationManager] - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@3 7b90c] for key [org.hibernate.impl.SessionFactoryImpl@55cf3f] bound to thread [http-8080-Processor24]
    [org.objectweb.jotm.jta] - Current.getStatus()
    [org.objectweb.jotm.jta] - threadTx.get= java.lang.ThreadLocal@1429498
    [org.objectweb.jotm.jta] - Transaction ret= bb14:38:0:01bf87ae53e759f101...cd0401:
    [org.objectweb.jotm.jta] - TransactionImpl.getStatus()
    [org.objectweb.jotm.jta] - status=STATUS_ACTIVE
    [org.hibernate.event.def.AbstractSaveEventListener] - executing identity-insert immediately
    [org.hibernate.jdbc.AbstractBatcher] - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    [org.hibernate.jdbc.ConnectionManager] - opening JDBC connection
    [org.enhydra.jdbc.xapool] - StandardDataSource:getConnection Connection from DriverManager is returned
    [org.hibernate.SQL] - insert into user (version, ...) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    [org.hibernate.id.IdentifierGeneratorFactory] - Natively generated identity: 25
    [org.hibernate.jdbc.AbstractBatcher] - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    [org.hibernate.jdbc.ConnectionManager] - aggressively releasing JDBC connection
    [org.hibernate.jdbc.ConnectionManager] - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    [org.springframework.transaction.interceptor.Transa ctionInterceptor] - Completing transaction for [com.p2ka.teeoff.service.user.UserFacade.addGeneral User] after exception: java.util.MissingResourceException: Can't find bundle for base name app_config, locale en_CA
    [org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute] - Applying rules to determine whether transaction should rollback on java.util.MissingResourceException: Can't find bundle for base name app_config, locale en_CA
    [org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute] - Winning rollback rule is: null
    [org.springframework.transaction.interceptor.RuleBa sedTransactionAttribute] - No relevant rollback rule found: applying superclass default
    [org.springframework.transaction.jta.JtaTransaction Manager] - Triggering beforeCompletion synchronization
    [org.springframework.transaction.support.Transactio nSynchronizationManager] - Removed value [org.springframework.orm.hibernate3.SessionHolder@3 7b90c] for key [org.hibernate.impl.SessionFactoryImpl@55cf3f] from thread [http-8080-Processor24]
    [org.springframework.orm.hibernate3.SessionFactoryU tils] - Closing Hibernate Session
    [org.springframework.transaction.jta.JtaTransaction Manager] - Initiating transaction rollback
    [org.objectweb.jotm.jta] - Current.getStatus()
    [org.objectweb.jotm.jta] - threadTx.get= java.lang.ThreadLocal@1429498
    [org.objectweb.jotm.jta] - Transaction ret= bb14:38:0:01bf87ae53e759f101...cd0401:
    [org.objectweb.jotm.jta] - TransactionImpl.getStatus()
    [org.objectweb.jotm.jta] - status=STATUS_ACTIVE
    [org.objectweb.jotm.jta] - Current.rollback()
    [org.objectweb.jotm.jta] - threadTx.get= java.lang.ThreadLocal@1429498
    [org.objectweb.jotm.jta] - Transaction ret= bb14:38:0:01bf87ae53e759f101...cd0401:
    [org.objectweb.jotm.jta] - threadTx.set= null
    [org.objectweb.jotm.jta] - TransactionImpl.rollback(tx= bb14:38:0:01bf87ae53e759f101...cd0401)
    [org.objectweb.jotm.jta] - status=STATUS_ACTIVE
    [org.objectweb.jotm.jta] - TransactionImpl.doDetach flag= TMSUCCESS
    [org.objectweb.jotm.jta] - number of enlisted= 0
    [org.objectweb.jotm] - transaction rolling back
    [org.objectweb.jotm.jta] - doBeforeCompletion committing= false
    [org.objectweb.jotm.jta] - unset timer for tx (timer=org.objectweb.jotm.TimerEvent@1aaf194, tx=bb14:38:0:01bf87ae53e759f101...cd0401)
    [org.objectweb.jotm.jta] - TimerEvent(bb14:38:0:01bf87ae53e759f101...cd0401). unset
    [org.objectweb.jotm.jta] - SubCoordinator.doRollback()
    [org.objectweb.jotm.jta] - doAfterCompletion()
    [org.objectweb.jotm.jta] - sychronization list size= 1
    [org.objectweb.jotm.jta] - Synchronization sync= org.hibernate.transaction.CacheSynchronization
    [org.objectweb.jotm.jta] - sync.afterCompletion status= STATUS_ROLLEDBACK
    [org.objectweb.jotm.jta] - remove tx from xid (xid=bb14:38:0:01bf87ae53e759f101...cd0401)
    [org.objectweb.jotm.jta] - SubCoordinator unexported [subcoord=org.objectweb.jotm.SubCoordinator@f7cbd1]
    [org.objectweb.jotm.jta] - remove tx from xid (xid=bb14:38:0:01bf87ae53e759f101...cd0401)
    [org.objectweb.jotm.jta] - reset timeout= 60
    [org.springframework.transaction.jta.JtaTransaction Manager] - Triggering afterCompletion synchronization
    [org.springframework.transaction.support.Transactio nSynchronizationManager] - Clearing transaction synchronization
    [AddUserPage] - Exception thrown in web layer: java.util.MissingResourceException: Can't find bundle for base name app_config, locale en_CA
    at java.util.ResourceBundle.throwMissingResourceExcep tion(ResourceBundle.java:836)
    at java.util.ResourceBundle.getBundleImpl(ResourceBun dle.java:805)
    at java.util.ResourceBundle.getBundle(ResourceBundle. java:549)
    at com.p2ka.teeoff.service.user.UserFacadeImpl.addUse r(UserFacadeImpl.java:204)
    </code>

    I wonder if there is any suggestion that I can try. Tks.

    P.S. I use JOTM & JTA because there are multiple datasources (Hibernate & JMS) that I need to write to.

  5. #5

    Default

    Google to the rescue

    http://docs.codehaus.org/display/JETTY/JOTM

    Using XAPool
    You MUST wrap the StandardXADataSource in a StandardXAPoolDataSource because StandardXADataSource does not use the XAConnection if you call getConnection(), thus connections won't be involved in the XA transaction.
    Also, check out this post: http://forum.springframework.org/showthread.php?t=13432

    Vitaliy

  6. #6
    Join Date
    Mar 2005
    Location
    Toronto, Canada
    Posts
    6

    Default

    I made the change, but it still didn't work. It was still have the same problem (transaction rolled back, but Hibernate committed the insert). I removed the code that intentionally throwing unchecked exception, and I found that there was a message "global transaction =<false>" (see debugging messages below). Is that mean the transaction manager still thought that it was a local transaction, so it didn't issue rollback to Hibernate when there was an error?

    Code:
    [org.objectweb.jotm.jta] - one phase commit with resource= StandardXAConnection:
         commit on prepare =<false>
         is closed =<false>
         this autoCommit =<true>
         listeners size =<1>
         next timeOut =<0>
         timeOut period =<60000>
         timeOut secs =<0>
         transaction manager=<org.objectweb.jotm.Current@cee41f>
    StandardXADataSource:
         connection count=<2>
         number of dead connection=<0>
         dead lock max wait=<300000>
         dead lock retry wait=<10000>
         driver=<com.mysql.jdbc.Driver@151fe8a>
         driver name=<com.mysql.jdbc.Driver>
         number of *free* connections=<1>
         max con=<0>
         min con=<50>
         prepared stmt cache size=<16>
         transaction manager=<org.objectweb.jotm.Current@cee41f>
         xid connection size=<1>
    StandardConnectionPoolDataSource:
         master prepared stmt cache size=<2>
         prepared stmt cache size =<16>
    StandardDataSource:
         driver=<com.mysql.jdbc.Driver@151fe8a>
         url=<jdbc:mysql://localhost:3306/my_app?useUnicode=TRUE&characterEncoding=UTF8>
         user=<root>
    CoreDataSource :
         debug =<false>
         description =<null>
         login time out =<60>
         user =<root>
         verbose =<false>
    StandardXADataSource:
         connection count=<2>
         number of dead connection=<0>
         dead lock max wait=<300000>
         dead lock retry wait=<10000>
         driver=<com.mysql.jdbc.Driver@151fe8a>
         driver name=<com.mysql.jdbc.Driver>
         number of *free* connections=<1>
         max con=<0>
         min con=<50>
         prepared stmt cache size=<16>
         transaction manager=<org.objectweb.jotm.Current@cee41f>
         xid connection size=<1>
    StandardConnectionPoolDataSource:
         master prepared stmt cache size=<2>
         prepared stmt cache size =<16>
    StandardDataSource:
         driver=<com.mysql.jdbc.Driver@151fe8a>
         url=<jdbc:mysql://localhost:3306/my_app?useUnicode=TRUE&characterEncoding=UTF8>
         user=<root>
    CoreDataSource :
         debug =<false>
         description =<null>
         login time out =<60>
         user =<root>
         verbose =<false>
    StandardXAConnectionHandle:
         global transaction =<false>
         is really used =<false>
         this autoCommit =<true>
         in use size =<0>
         master prepared stmt cache size =<2>
         transaction =<null>
         connection =<com.mysql.jdbc.Connection@1e45e3>
    com.mysql.jdbc.Connection@1e45e3
    
    2007-04-20 10:31:44,096 DEBUG [org.enhydra.jdbc.xapool] - StandardXAConnection:commit perform a commit
    
    2007-04-20 10:31:44,096 DEBUG [org.enhydra.jdbc.xapool] - StandardXADataSource:getConnection (xid=bb14:38:40:013511112e87c160fb...701003:013511112e87c160fbbf6...000000, mustFind=true)
    
    2007-04-20 10:31:44,096 DEBUG [org.enhydra.jdbc.xapool] - XID: StandardXAStatefulConnection:
         commit on prepare =<false>
         timed out =<false>
         id =<2>
         state =<0>
         time out =<0>
         xid =<bb14:38:40:013511112e87c160fb...701003:013511112e87c160fbbf6...000000>
    The following is my latest Spring configurations related to datasource & transaction:

    Code:
    	<bean id="innerDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
    		<property name="transactionManager">
    			<ref local="jotm"/>
    		</property>
    		<property name="driverName">
    		<value>com.mysql.jdbc.Driver</value>
    		</property>
    		<property name="url">
    		<value>jdbc:mysql://localhost:3306/my_app?useUnicode=TRUE&amp;characterEncoding=UTF8</value>
    		</property>
    		<property name="user">
    		<value>root</value>
    		</property>
    		<property name="password">
    		<value></value>
    		</property>
    	</bean>
                 <bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
    		<property name="dataSource"><ref local="innerDataSource"/></property>
    		<property name="maxSize"><value>5</value></property>
    		<property name="minSize"><value>2</value></property>
    		<property name="user"><value>root</value></property>
    		<property name="password"><value></value></property>
    	</bean>
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref local="dataSource"/>
    		</property>
    		<property name="mappingResources">
    			<list>
    				<value>Role.hbm.xml</value>
    				<value>User.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    				<prop key="hibernate.query.substitutions">true=1 false=0</prop>
    				<prop key="hibernate.show_sql">true</prop>
    			</props>
    		</property>
    		<property name="jtaTransactionManager">
    			<bean id="transactionManager.transactionManager" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    		</property>
    	</bean>
    	<bean id="userDAO" class="UserDAOImpl">
    		<property name="sessionFactory">
    			<ref local="sessionFactory"/>
    		</property>
    	</bean>
    	<bean id="userFacadeImpl" class="UserFacadeImpl">
    		<property name="userDAO">
    			<ref bean="userDAO"/>
    		</property>
    	</bean>
    	<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/>
    	<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    		<property name="userTransaction">
    			<ref local="jotm"/>
    		</property>
    	</bean>
    	<bean id="userFacade" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager">
    			<ref local="transactionManager"/>
    		</property>
    		<property name="target">
    			<ref local="userFacadeImpl"/>
    		</property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="addGeneralUser">
    					PROPAGATION_REQUIRED
    			    </prop>
    			</props>
    		</property>
    	</bean>
    I wonder if you can spot anything wrong with the configurations. Thanks alot, once again.

  7. #7
    Join Date
    Jan 2008
    Posts
    9

    Default JOTM + Hibernate + Spring for XA Transactions

    Hi pcheung

    Looks like a very old thread , but if you are still getting mails from the forum

    I am also, using JOTM + Hibernate + Spring for XA Transactions. Did you get that to work . I am getting similar issues . Looks like Hibernate is not joining the Transaction with JOTM . If it worked for you , & if you don't mind , can you share your final configuration . I am really stuck & need help.

    Thanks
    Shipra

Posting Permissions

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