Hi all, please can you help me with this, its driving me crazy!
I'm experiencing the following exception: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
It seems this exception is being thrown on the completion of the 'getNextJobForDevice' method outlined below. From what I can tell it seems that the when the implicit transaction for the 'jobFacadeLocal.print(job, device)' device is committed, we can no longer use any entities that were updated in this transaction. (I'm using container managed transactions)
I've tried to refresh the object from the database after this transaction. I've tried using the entityManager.refresh() mehtod to do this, but it seems to return the entity without any changes committed from the 'jobFacadeLocal.print(job, device)' method. I don't quite understand this since I'm expecting the changes to have committed as this stage. I've also tried the ((Session)entityManager.getDelegate()).refresh(t); approach and still no luck!
I'd greatly appreciate some help on this since I've been trying to find a solution for a while now with not luck. Even a link to point me in the right direction would be greatly appreciated at this time.
Thank you for your time in advance.
Regards
Drayton
@Stateless
@WebService
public class Spooler implements SpoolerLocal {
...
public Job getNextJobForDevice(String deviceName) throws SpoolerException {
...
List<Job> jobs = jobFacadeLocal.findPendingByStockTypes(device.getStockTypes());
for (Job job : jobs) {