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

Jeremy Grodberg (JIRA) noreply at atlassian.com
Tue Feb 26 01:01:33 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29586 ] 

Jeremy Grodberg commented on HHH-2525:
--------------------------------------

I'm having the same (or at least a similar) problem with a native SQL query which has a result transformer, again only when it is cached.  Other than turning off the cache, it's hard for me to work around this, since the result transformers are applied in named SQL queries and have the added benefit of projecting column names into the queries.

(Reminder to watchers: vote on this bug if you want it fixed)

Note my stack trace diverges from the reporters where his call emanates from org.hibernate.loader.hql.QueryLoader.list, mine emanates from org.hibernate.loader.custom.CustomLoader.list.

Note also that this stack trace is from 3.2.6.ga under Java 1.5.0_11


org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.modernfeed.modfeed.domain.Program.programId
	at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:35)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
	at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3596)
	at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3312)
	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:2187)
	at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2138)
	at org.hibernate.loader.Loader.list(Loader.java:2096)
	at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
	at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
	at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
	at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at my code calling query.list();

Caused by: java.lang.IllegalArgumentException
	at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
	at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
	at java.lang.reflect.Field.get(Field.java:357)
	at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32)
	... 93 more



> 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