Hello,

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

em.getTransaction().begin();
try {
// get a hold of JDBC connection so we can join transaction
OpenJPAEntityManager emo = (OpenJPAEntityManager) em;
Connection connection = (Connection) emo.getConnection();
// ... do JDBC insert
connection.executeUpdate(...);
em.merge(this);
em.getTransaction().commit();
} 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?

Thanks.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
http://www.opentempo.com
mailto:daryl.stu...@opentempo.com

Reply via email to