|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
JTA Spring 2.0.2 + Jencks 2.0 + Hibernate 3.2.1 - Transaction Rollback ProblemHibernate 3.2
Spring 2.0.2 Jencks 2.0 MS SQL Server 2000 I am having problems getting JTA to work properly within my Spring 2.0.2 application utilizing Jencks 2.0. What I am attempting to do is use transaction suspension and using the REQUIRES_NEW annotation to accomplish this. Note: I am only using one datasourcs so I am don't need any XA The following is annotation that I have defined on a given service method. @Transactional(propagation=Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = {BusinessException.class }) public void myTransactionalServiceMethod() throws BusinessException @Transactional(propagation=Propagation.REQUIRED, readOnly = false, rollbackFor = { {BusinessException.class, DataAccessException.class }) public void serviceMethodSave(Object o) throws BusinessException When testing, I force the myTransactionalServiceMethod() method to throw a BusinessException directly after the call to serviceMethodSave which issues a call to a Hibernate DAO to save the object. I would expect the transaction would be rolledback but that is not happening. I am not getting any exceptions thrown when the code is executed just unexpected results. Here is my Spring / Hibernate configurations: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <tx:annotation-driven transaction-manager="jtaTransactionManager" /> <bean id="transactionManager" class="org.jencks.factory.TransactionManagerFactoryBean" /> <bean id="connectionManager" class="org.jencks.factory.ConnectionManagerFactoryBean"> <property name="transactionManager" ref="transactionManager"/> </bean> <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="userTransaction" ref="transactionManager" /> </bean> <bean id="jdbcManagedConnectionFactory" class="org.jencks.tranql.DataSourceMCF"> <property name="driverName" value="${hibernate.connection.driver_class}"/> <property name="url" value="${hibernate.connection.url}"/> <property name="user" value="${hibernate.connection.username}"/> <property name="password" value="${hibernate.connection.password}"/> </bean> <bean id="dataSource" class="org.jencks.factory.ConnectionFactoryFactoryBean"> <property name="managedConnectionFactory" ref="jdbcManagedConnectionFactory"/> <property name="connectionManager" ref="connectionManager"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="jtaTransactionManager"> <bean factory-bean="jtaTransactionManager" factory-method="getTransactionManager"/> </property> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="configurationClass"> <value>org.hibernate.cfg.AnnotationConfiguration</value> </property> <property name="annotatedClasses"> ....... </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.connection.show_sql}</prop> <prop key="hibernate.debug">${hibernate.connection.debug}</prop> <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop> <prop key="hibernate.connection.release_mode">after_transaction</prop> <prop key="hibernate.cglib.use_reflection_optimizer">true</prop> <prop key="hibernate.transaction.flush_before_completion">true</prop> <prop key="hibernate.transaction.auto_close_session">true</prop> <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop> <prop key="hibernate.current_session_context_class">thread</prop> </props> </property> </bean> </beans> If anyone could provide any insight as to why I may be experiencing this behavior I would greatly appreciate it. Cheers, Zenon |
| Free embeddable forum powered by Nabble | Forum Help |