This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Reading Uncommitted Data" Watch "Reading Uncommitted Data" New topic
Author

Reading Uncommitted Data

Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    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
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    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.
 
GeeCON Prague 2014
 
subject: Reading Uncommitted Data