aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Data updated through stored proc is not retrieved by subsequent em.find() calls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Data updated through stored proc is not retrieved by subsequent em.find() calls" Watch "Data updated through stored proc is not retrieved by subsequent em.find() calls" New topic
Author

Data updated through stored proc is not retrieved by subsequent em.find() calls

Pushker Chaubey
Ranch Hand

Joined: Dec 06, 2006
Posts: 53
Hi experts,

I am facing a very interesting problem. After updating an entity through EntityManager API, I update the data through a stored proc via a jdbc connection object. both the updates - done by em and stored proc are reflected in database. Then in another call to em.find() is made but that does not reflect the changes done by stored proc.

the code flow looks like the following...

..
..//do some changes in entity
..
em.flush();

callToStoredProc(); // this method invokes stored proc via connection object obtained from datasource and does updates

em.clear();
..


And then from within another session bean I call em.find() which does gives me back the data updated through stored proc.

Please provide solutions to my problem.

Thanks in advance!

regards,
Pushker Chaubey
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10213
    
166

What's the connection isolation level on the datasource?

[My Blog] [JavaRanch Journal]
Pushker Chaubey
Ranch Hand

Joined: Dec 06, 2006
Posts: 53
Hi,

Thanks for showing interest in this problem. I am not sure about isolation level and code is not available right now, so can't look into.
Please let me know in this situation what should be the isolation level set to for data-source connections and for Entitymanager settings? your inputs please...

Also, please note that we are using container managed transaction here and we have NOT declared any transaction attribute on the method callToStoredProc(). I believe though the method callToStoredProc() executes in the propagated transaction, the updates done using connection object are NOT going to be in the same transaction. Please correct me if I am wrong.

We are using Hibernate's JPA provider. Though we were able to get around the problem by getting access to hibernate session factory and then evicting the entity. But here the use of Hibernate's proprietary API is not being accepted and they want me to use only standard JPA APIs to fix it (In order to have no dependency on underlying JPA provider).

Your input are welcome.

Regards,
Pushker Chaubey
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Data updated through stored proc is not retrieved by subsequent em.find() calls