[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2525) Bug when using a ResultTransformer on a cached query

Sebastien Cesbron (JIRA) noreply at atlassian.com
Tue Mar 27 08:15:04 EDT 2007


Bug when using a ResultTransformer on a cached query
----------------------------------------------------

                 Key: HHH-2525
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2525
             Project: Hibernate3
          Issue Type: Bug
          Components: core
    Affects Versions: 3.2.2
         Environment: Firebird 2.0 on Win XP
            Reporter: Sebastien Cesbron
         Attachments: testhib.zip

Using a distinct result transformer which a cached like this :

query = session.createQuery("select obj from ObjetTest obj left outer join fetch obj.children as obj_0 order by obj.id asc");
query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
query.setCacheable(true); 
query.list();

This leads to this exception

2007-03-21 14:28:20,589 ERROR : IllegalArgumentException in class: ObjetTest, getter method of property: oid
Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of ObjetTest.oid
   at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
   at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3524)
   at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3240)
   at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
   at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:218)
   at org.hibernate.type.ManyToOneType.disassemble(ManyToOneType.java:163)
   at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:80)
   at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2118)
   at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2062)
   at org.hibernate.loader.Loader.list(Loader.java:2020)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
   at Test.main(Test.java:33)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
   ... 16 more

It seems this is due to a difference in QueryLoader.getResultColumnOrRow. In this method there is a test :

else if ( !hasTransform ) {
   return row.length == 1 ? row[0] : row;
}

This causes the method to return an instance of ObjetTest in one case and an instance of ObjetTest[1] in the other one. In the latter test, when putting the query into the query cache, hibernate calls the getOid method on an array of ObjetTest and this causes the exception

-- 
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