]
Gail Badner updated HHH-5849:
-----------------------------
Fix Version/s: (was: 3.6.4)
4.0.0.Beta1
3.6.5
AbstractQueryImpl loads non readOnly entity with
session.setDefaultReadOnly(true)
---------------------------------------------------------------------------------
Key: HHH-5849
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5849
Project: Hibernate Core
Issue Type: Bug
Components: query-hql, query-sql
Affects Versions: 3.6.0
Reporter: Jan Hodac
Assignee: Gail Badner
Fix For: 3.6.5, 4.0.0.Beta1
When I need all loaded entities to be readOnly I use session.setDefaultReadOnly(true);
Example:
@javax.persistence.NamedQuery(name="TEST", query="select p from Person
p")
session.setDefaultReadOnly(true);
Object object = session.getNamedQuery("TEST").uniqueResult();
assertEquals(true,session.isReadOnly(object));
but entity loaded by named query is non readOnly
Problem is in AbstractQueryImpl#isReadOnly(). Field readOnly never can be null
/**
* {@inheritDoc}
*/
public boolean isReadOnly() {
return ( readOnly == null ?
getSession().getPersistenceContext().isDefaultReadOnly() :
readOnly.booleanValue()
);
}
/**
* {@inheritDoc}
*/
public Query setReadOnly(boolean readOnly) {
this.readOnly = Boolean.valueOf( readOnly );
return this;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: