• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the connection isolation level on the datasource?
 
Pushker Chaubey
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic