File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Pushker Chaubey
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the connection isolation level on the datasource?
 
Pushker Chaubey
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic