wood burning stoves 2.0*
The moose likes Spring and the fly likes How to mix JPA and JDBC transaction? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to mix JPA and JDBC transaction?" Watch "How to mix JPA and JDBC transaction?" New topic
Author

How to mix JPA and JDBC transaction?

Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 484
    
    2

Hi folks

I am desperately looking for information on how to configure the transaction org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport to be executed within the transaction org.springframework.orm.jpa.JpaTransactionManager.
I've tried to do what the documentation showed me but still did not work ..
Has anyone done or know of any tutorial?


Fernando Franzini - Java Blog
Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 484
    
    2

I just solve!!

In Class JpaTransactionManager say:
Note: To be able to register a DataSource's Connection for plain JDBC code, this instance needs to be aware of the DataSource (setDataSource(javax.sql.DataSource)). The given DataSource should obviously match the one used by the given EntityManagerFactory. This transaction manager will autodetect the DataSource used as known connection factory of the EntityManagerFactory, so you usually don't need to explicitly specify the "dataSource" property.

and you need create a special bean to mix transaction like this:

<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
<bean id="transacaoJPA" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf"/>
<property name="dataSource" ref="poolBean"/>
<property name="jpaDialect" ref="jpaDialect"/>
</bean>
See yaa
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to mix JPA and JDBC transaction?
 
Similar Threads
Hibernate Transaction - CMT
Transaction in JDBC?
SCJP 1.5 Voucher sale for $220
session.flush(); gives null
WA #1.....word association