• 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

How to read my own uncommitted data but not others'

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While using a transaction, it seems that after I read data, say A, from database, make changes to it to change it to B, update the database and then I read the database again, before committing, I get the original data, A.

Is there a way for me to get the changed data, B, without getting dirty data from other transactions?

I am doing this in EJB3.0

Thanks in advance.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a bit rusty on this, but check the get/setTransactionIsolation methods of the java.sql.Connection class. One of the levels should provide this. I'm not sure how to tell EJB to use a particular level, though, but I seem to remember that it is possible (provided the underlying DB supports that particular level).
 
Anne Forumer
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll appreciate any definitive answers on this!

If I use isolation level of uncommitted read, I could read data in another transaction, which I don't want. Also, I want to read this data before I commit, so I wouldn't want "committed read" either. Am I asking for something impossible?

To reiterate, I'd like to read my own updated data, not yet committed.

Thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anne,
I'm moving this to the JPA (EJB 3.0) forum. EJB 3.0 caches data and only commits at the end of the transaction or when you specify to flush. This means the effects involve more than just the transactions of JDBC.
 
reply
    Bookmark Topic Watch Topic
  • New Topic