I'm trying to figure out what is going on but, from what I can tell it looks like the Session 'at random' is detaching entities that were previously created on that same session..i.e. 9/10 times the code below works just fine..
Essentially the code is doing the following: (entity is created/commit in transaction 1, then later updates (on the same session) on a different transaction..and ~1/10 times it fails due to detached entity.
Code:
tx = getEntityManager().getTransaction(); // (bound to threadLocal..or created if one not already created)
tx.begin()
Pojo pojo = new Pojo();
Pojo2 pojo2 = new Pojo2();
pojo2.setPojo(pojo);
tx.commit();
..
..
tx = getEntityManager().getTransaction(); // return threadLocal entityManger or one created (verified same address as one above)
tx.begin();
pojo.setStatus("success");
tx.commit(); <-- PersistenceException detatched entity passed ..Pojo
so my question is..I have full hibernate logging turned on, yet..I see no messages indicating if/when the entities are getting detached...
Is there anything I can look for explictly in the logs to see when/where/what is getting detached when?...obviuosly I can 're-attach by issue a new query, but that feels wrong, and obviously is performance hit).
any thoughts/pointers?