File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Reading Uncommitted Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Reading Uncommitted Data" Watch "Reading Uncommitted Data" New topic
Author

Reading Uncommitted Data

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

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: 3697
    
    5

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://aspose.com/file-tools
 
subject: Reading Uncommitted Data
 
Similar Threads
Problems understanding EJB transactions and isolation
How to update an entity when the persistence context is extended?
long post IBM.158
My SCEA Part 1Study Notes
JPA - Optimistic Lock and JTA Transaction