[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5849) AbstractQueryImpl loads non readOnly entity with session.setDefaultReadOnly(true)

Jan Hodac (JIRA) noreply at atlassian.com
Tue Jan 18 07:07:05 EST 2011


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


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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list