Thank you Marten.
I read the reference guide but my situation seems to be quite different. May be my interpretation is wrong.
I don't want to change the legacy code which obtains connection using code:
Code:
Driver dbDriver = (Driver) Class.forName(sDriver).newInstance();
Connection conn = dbDriver .connect(url, info);
Legacy does its stuff with the above connection [stuff-A] and then I use spring to do my enhacement stuffs [stuff-B] which uses its own connection with the custom datasource supplied in xml.
Spring code:
Code:
<bean id="myJPAEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:com/myProject/data/persistence.xml" />
<property name="persistenceUnitName" value="default" />
<property name="dataSource" ref="myCustomDataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
<property name="showSql" value="true" />
</bean>
</property>
</bean>
<tx:annotation-driven transaction-manager="jpaTransactionManager" />
<bean id="jpaTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="myJPAEntityManagerFactory" p:dataSource-ref="myCustomDataSource" />
As there are two differenct connections I feel they are bound to different transactions and if stuff-B fails then stuff-A is not rolled back.
Appreciate your help.