This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to mix JPA and JDBC transaction?  RSS feed

 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!