openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <>
Subject JDBC operation in JPA transaction
Date Thu, 15 Sep 2011 20:00:04 GMT

consider the following code in an entity "save" method:

try {
// get a hold of JDBC connection so we can join transaction
OpenJPAEntityManager emo = (OpenJPAEntityManager) em;
Connection connection = (Connection) emo.getConnection();
// ... do JDBC insert
} catch (...) {

The idea is to start a transaction on the EM, perform an operation in JDBC,
then commit the EM transaction. When the commit fails the JDBC operation is
successful. I expected the rollback of the transaction to rollback the
operation on the JDBC connection, too. Am I doing this right? How can I
perform a JDBC operation in a JPA transaction and have it rolled back upon
failure of commit?


Daryl Stultz
6 Degrees Software and Consulting, Inc.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message