Jayr Motta
Jayr Motta

Reputation: 718

Transaction propagation and Persistence Context synchronization with Oracle Stored Procedures

I've been searching about the possibility of propagate a JTA transaction from Java code to Oracle stored procedures and found nothing really relevant. I'm asking this because a coworker is working with this and told me that it worked for him.

What I'm wondering is a situation where some operation have not been flushed because the transaction is still opened and subsequently a stored procedure is called (this procedure doesn't control it's own transaction), will the stored procedure be able to see the pendent operation in the Persistence Context? In other words, will the Persistence Context synchronize somehow with the transactional memory of the underneath database?

I'm studying for the Oracle JPA exam and such thing is not described in the book I'm reading. However I've read in some websites that I googled and people say that such transaction propagation works because there are an integration between JTA and database transactions in certain JDBC drivers (I just can't imagine how it could work, are the transaction manager aware of database transactions??).

Thanks in advance!

Upvotes: 0

Views: 1267

Answers (1)

Amir Pashazadeh
Amir Pashazadeh

Reputation: 7282

I've done the same thing using Spring+Hibernate, and home-grown framework+Hibernate. I believe the same thing shall work with JPA.

If you are calling your SP inside the same transaction as you do JPA, everything goes fine, the only problem is what you mentioned, so just call flush() on your persistenceManager before calling the SP, and the modification you made on your entities will be written to DB in the context of the transaction.

Upvotes: 2

Related Questions