I\'m getting the good, old and dreaded TransientObjectException
, and, as often happens in such case, I\'m having problems locating what kind of subtle bug in the co
Found @nakosspy post very useful. Inspired by his post, I added this very simple utility method that outputs the contents of Hibernate Session.
As nakosspy said this is ONLY for debugging purposes as it is a HACK.
public static void dumpHibernateSession(Session s) {
try {
SessionImplementor sessionImpl = (SessionImplementor) s;
PersistenceContext persistenceContext = sessionImpl.getPersistenceContext();
Field entityEntriesField = StatefulPersistenceContext.class.getDeclaredField("entityEntries");
entityEntriesField.setAccessible(true);
IdentityMap map = (IdentityMap) entityEntriesField.get(persistenceContext);
log.info(map);
} catch (Exception e)
{
log.error(e);
}
}