This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to read my own uncommitted data but not others'

 
Anne Forumer
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35976
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!