Hello all
iam trying to execute a simple Criteria Query
the query is as follows
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(MyClass.class);
detachedCriteria.add(Restrictions.lt("day", new Date()));
detachedCriteria.add(Restrictions.eq("contentType", "xyz"));
detachedCriteria.createAlias("userContent", "userContent");
detachedCriteria.setProjection(Projections.projectionList()
.add(Projections.alias(Projections.sum("count"),"sumAlias"))
.add(Projections.groupProperty("userContent"))
).addOrder(Order.desc("sumAlias"));
detachedCriteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
This query translates to the following pseudo SQL
"Select sum(count),content_id from ....group by Content_id order by sum(count)"
when i run this with the query cache off it works fine and returns me a list of content objects i.e it uses the content_id from the query and gets me a list of content items
but with the query cache turned on i get
java.lang.ClassCastException
at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:77)
at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2119)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2063)
at org.hibernate.loader.Loader.list(Loader.java:2021)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at test.hibernate.spring.DAOTester$1.doInHibernate(DAOTester.java:199)
Seems like this piece of code in the StandQueryCache
"
cacheable.add( TypeFactory.disassemble( (Object[]) result.get(i), returnTypes, null, session, null ) );"
is casting the "transformed" object to an Object[] ...
any ideas if iam doing something wrong or if this is a bug ?
Using Hib 3.1.3
|