It's not a secret anymore!
The moose likes Object Relational Mapping and the fly likes Reading Uncommitted Data Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Reading Uncommitted Data" Watch "Reading Uncommitted Data" New topic
Author

Reading Uncommitted Data

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

I have large process X running inside an EJB and I would like to monitor its status from the web by checking the values of certain rows in the database. The problem is the default settings make it so that I can only see the changed values after the process X is finished. In short, I want to read the data from the entity manager from the web (which is using the same EJB session bean) while process X is still running.

I couldn't find a way to change the isolation for a single transaction (missing feature?), but I did see I can modify isolation-level in the data source XML file to "TRANSACTION_READ_UNCOMMITTED". The problem is, this still does not work by itself, I also have to call entityManager.flush(). Calling flush hundreds/thousands of times during a transaction seems like it would hurt DB performance, shouldn't the web application (which is accessing the same session bean as process X) be able to read the entity manage data without the call to flush?


My Blog: Down Home Country Coding with Scott Selikoff
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

By the way, the only other solution that I know works and doesn't hit the database/flush unnecessarily is track the progress in a static/singleton object. This seems to defeat the purpose of having an 'entity manager' though.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Reading Uncommitted Data
 
Similar Threads
Problems understanding EJB transactions and isolation
long post IBM.158
JPA - Optimistic Lock and JTA Transaction
My SCEA Part 1Study Notes
How to update an entity when the persistence context is extended?