• 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: 42969
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
Marshal
Posts: 35279
384
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic