I need to configure hibernate session factory to talk to an existing datasource configured in weblogic 10.3.3. am using spring 4.x and hibernate 4.x
This datasource supports Global transactions and emulates One-phase commit
Have several questions:
what transaction manager should I use - I am assuming that since my datasource supports Global Tx - it should be a JTA datasource ?
This is what I have:
spring application context:
<bean id="sessionFactoryCommon"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:COMMON.hibernate.cfg.xml" />
</bean>
<bean id="transactionManagerCommon"
class="org.springframework.transaction.jta.WebLogicJtaTransactionManager" />
<tx:annotation-driven transaction-manager="transactionManagerCommon" />
<bean id="pitHibDao"
class="com.abc.PitDaoHibernate"
lazy-init="true">
<property name="sessionFactoryCommon" ref="sessionFactoryCommon" />
</bean>
The file - COMMON.hibernate.cfg.xml contains:
<hibernate-configuration>
<session-factory>
<!-- this is jndi name of weblogic datasource -->
<property name="connection.datasource">DSECRDS1</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
<property name="default_schema">ABC</property>
</session-factory>
</hibernate-configuration>
My Dao uses the @Transactional annotation - but when I run this code I get an exception - org.hibernate.HibernateException: No Session found for current thread
If I change my datasource to not participate in global transaction - this code works fine - but I need this to work in a datasource that supports global transaction
Aucun commentaire:
Enregistrer un commentaire