Hibernate version: 3.1
Seeing as setReadOnly(Object, boolean) is a brand new method for Hibernate 3.1, I was wondering if this was my own mis-use of it, or if it's a bug. The objects passed into the method are very definitely associated with the session.
Thank you for your interest,
Relevent code snippet between sessionFactory.openSession() and session.close():
Code:
if(readOnly)
{
Class clazz = persistable.getClass();
if(clazz.getName().contains("EnhancerByCGLIB"))
{
clazz = clazz.getSuperclass();
}
persistable = (Persistable) session.get(clazz, persistable.getIdentifier());
}
else
{
persistable = (Persistable) session.merge(persistable);
}
logger.debug("session.contains(" + persistable + ") -> " + session.contains(persistable));
// This method is Hibernate 3.1 only
session.setReadOnly(persistable, readOnly);
Full stack trace of any exception that occurs:Code:
DEBUG:eg.persistence.HibernatePersister.bind(HibernatePersister.java:106) session.contains(Workflow[@d92304] -> true
DEBUG:eg.persistence.HibernatePersister.bind(HibernatePersister.java:106) session.contains(BusinessDTO@136daec) -> true
DEBUG:eg.persistence.HibernatePersister.bind(HibernatePersister.java:106) session.contains(Company@26c3a1) -> true
ERROR:eg.web.PersistenceFilter.doFilter(PersistenceFilter.java:63) Instance was not associated with the session
org.hibernate.TransientObjectException: Instance was not associated with the session
at org.hibernate.engine.StatefulPersistenceContext.setReadOnly(StatefulPersistenceContext.java:1167)
at org.hibernate.impl.SessionImpl.setReadOnly(SessionImpl.java:1740)
at eg.persistence.HibernatePersister.bind(HibernatePersister.java:108)