[Hibernate-JIRA] Created: (HHH-5849) AbstractQueryImpl loads non readOnly entity with session.setDefaultReadOnly(true)
by Jan Hodac (JIRA)
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months
[Hibernate-JIRA] Created: (HHH-4760) NotAuditedException occurs when auditReader.getRevisions() is called for javassist proxies
by Erik-Berndt Scheper (JIRA)
NotAuditedException occurs when auditReader.getRevisions() is called for javassist proxies
------------------------------------------------------------------------------------------
Key: HHH-4760
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4760
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.0-Beta-2
Reporter: Erik-Berndt Scheper
NotAuditedException occurs when auditReader.getRevisions() is called for javassist proxies
In my code I see the following stacktrace if I try to retrieve the revision of a javassist proxy:
org.hibernate.envers.exception.NotAuditedException: nl.ibgroep.bap.model.domain.persoon.Ouder_$$_javassist_1 is not versioned!
at org.hibernate.envers.reader.AuditReaderImpl.getRevisions(AuditReaderImpl.java:126)
at nl.ibgroep.bap.dao.impl.AuditRevisionJpaDaoImpl.getRevisionsFor(AuditRevisionJpaDaoImpl.java:58)
Ouder_$$_javassist_1.class is a Hibernate generated javassist proxy for Ouder.class, which is versioned.
Code:
AuditReader vr = AuditReaderFactory.get(this.entityManager);
Class clazz = persistentObject.getClass();
List<Number> revisionNumbers = vr.getRevisions(clazz, persistentObject.getId());
I am able to work around this issue with the following code:
AuditReader vr = AuditReaderFactory.get(this.entityManager);
Class clazz = persistentObject.getClass();
if (persistentObject instanceof javassist.util.proxy.ProxyObject) {
if (LOGGER.isDebugEnabled()) {
StringBuilder output = new StringBuilder("Found javassist ProxyObject for revision: class= ");
output.append(clazz.getSimpleName());
output.append("; superclass= ").append(clazz.getSuperclass().getSimpleName());
output.append("; interfaces= ").append(Arrays.asList(clazz.getInterfaces()).toString());
LOGGER.debug(output.toString());
}
clazz = clazz.getSuperclass();
}
List<Number> revisionNumbers = vr.getRevisions(clazz, persistentObject.getId());
However, a fix in envers would be greatly appreciated.
--
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
12 years, 10 months
[Hibernate-JIRA] Commented: (HHH-951) setMaxResults causes "ORA-00918: column ambiguously defined" exception
by Paweł Kępka (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-951?page=co... ]
Paweł Kępka commented on HHH-951:
---------------------------------
I had a problem similar to the one described by Grzegorz Olędzki. The patch suggested by him seems to solved it. Moreover it reduces number of data retrieved on other databases. Is there a chance to apply it to any upcoming release of Hibernate?
> setMaxResults causes "ORA-00918: column ambiguously defined" exception
> -----------------------------------------------------------------------
>
> Key: HHH-951
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-951
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5, 3.1 beta 2, 3.5.3, 3.6.1
> Environment: hibernate3.0.5, hibernate3.1b2, Oracle 9
> Reporter: Karel Sommer
> Attachments: HHH951Project.zip, Hibernate_SQL_HHH-5579.txt, Hibernate_StackTrace_HHH-5579.txt, patch.951, TestCase_for_Hibernate_Core_Issue_HHH-5579.zip
>
>
> when create criteria with associations, i get this error:
> ORA-00918: column ambiguously defined
> mapping:
> <class name="User" table="FRAME_USER" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_user_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="user_name" type="string" not-null="true"/>
> <property name="blocked" type="yes_no" not-null="true"/>
> <property name="access_logon" type="timestamp"/>
> <property name="denied_logon" type="timestamp"/>
> <property name="inactivity_time" type="long"/>
> <property name="session_count" type="long"/>
> <idbag name="terminalGroups" table="FRAME_USER_TERMINAL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long">
> <generator class="sequence">
> <param name="sequence">frame_user_terminal_seq</param>
> </generator>
> </collection-id>
> <key column="id_user"/>
> <many-to-many column="id_terminal_groups" class="TerminalGroup" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="TerminalGroup" table="FRAME_TERMINAL_GROUPS" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_groups_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="name" column="group_name" type="string" not-null="true"/>
> <idbag name="terminals" table="FRAME_TERMINAL_REL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long" >
> <generator class="sequence">
> <param name="sequence">frame_terminal_rel_seq</param>
> </generator>
> </collection-id>
> <key column="id_term_group"/>
> <many-to-many column="id_term" class="Terminal" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="Terminal" table="FRAME_TERMINAL" where="status != 'D'" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="status" type="char" not-null="true"/>
> <property name="mac" type="string" not-null="true"/>
> <property name="name" column="ident" type="string" not-null="true"/>
> <property name="description" type="string"/>
> code:
> session.createCriteria(User.class)
> .add(Restrictions.like("user_name", "%")
> .createCriteria("terminalGroups")
> .add( Restrictions.like("group_name", "%").
> .setProjection(Projections.rowCount())
> .uniqueResult();
--
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
12 years, 10 months