IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes How to read my own uncommitted data but not others' Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "How to read my own uncommitted data but not others Watch "How to read my own uncommitted data but not others New topic
Author

How to read my own uncommitted data but not others'

Anne Forumer
Ranch Hand

Joined: Apr 19, 2004
Posts: 70
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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32765
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).


Android appsImageJ pluginsJava web charts
Anne Forumer
Ranch Hand

Joined: Apr 19, 2004
Posts: 70
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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23628

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
 
 
subject: How to read my own uncommitted data but not others'
 
Threads others viewed
Problem In EJB Transaction Management
.NET dataset in java
OutOfMemoryError at the time of batch run
B&S: Data Layer Design with Singleton?
how to solve the data problem when we don't have backend database support?
IntelliJ Java IDE