[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1352?page=c...
]
Steve Ebersole commented on HHH-1352:
-------------------------------------
There are internal details, but the basic difficulty here is that "read only" is
tracked on the o.h.engine.EntityEntry class. EntityEntry is only created and tracked for
*initialized* entities. Proxies currently have no way to track there "read
only" state. Your patch is making the assumption that the whole entire session will
be in "read only" (at least when the proxy data is being fetched).
So either we need to decide if it is better to:
1) add an "entry" object that describes proxies (largely it would be a
placeholder for data that needs to transfer over to the EntityEntry after fetch).
2) create an entity entry instance for proxies.
Session.setReadOnly(Object, boolean) fails for proxies
------------------------------------------------------
Key: HHH-1352
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1352
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.1
Environment: Hibernate 3.1, MySQL 5.0.15-nt
Reporter: Stewart Cambridge
Assignee: Steve Ebersole
Priority: Minor
Original Estimate: 1 day
Remaining Estimate: 1 day
Session.setReadOnly(Object, boolean) is broken. It throws a TransientObjectException with
the message "Instance was not associated with the session" when the object is
quite obvious associated with the current session, because we only just loaded it using
Session.load(Class, Serializable)
Here is a simple JUnit test, for an arbitrary entity:
public void testReadOnly()
throws Exception
{
User user = (User) session.load(User.class, new Long(7));
System.out.println("\n=== " + user + " ===");
session.setReadOnly(user, true);
}
This is the exception stack trace:
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
test.persistence.HibernateObjectTest.testReadOnly(HibernateObjectTest.java:30) ....
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira