I am working with Spring 3.2.5.Release and Hibernate 4.2.7.Final. I am deploying my ear on Websphere 7 server. I have two application context files and each has its own sessionFactory of type
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">....</bean>
<bean id="sessionFactory1"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" lazy-init="true">... </bean>
The issue is with multiple HibernateTransactionManager. I am defining two transaction managers as
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<qualifier value="transactionManager"/>
</bean>
and
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory1" />
<qualifier value="txManager"/>
</bean>
In one of the context files I have mentioned this
<tx:annotation-driven/>
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
However, during runtime of this code,
loggingManager.persistLog(loadLog); // using txManager
.....
persistenceService.persist(dataEntity); // using transactionManager
I get the below exception
org.springframework.transaction.IllegalTransactionStateException: No existing transaction found for transaction marked with propagation 'mandatory'
Please note that the first transaction is success. I see the id generated for loadLog. I've annoted my Service layer with
@Transactional(value="txManager") // with respective transaction manager
And my DAO layer with
@Transactional(propagation = Propagation.MANDATORY)
Is there anything that could be done to enable both the transaction managers?