I just wanted to report a problem that I found with Hibernate 3.2. I did not build any of our hibernate infrastructure but I encountered this problem trying to run a particular query, after L2 caching was added. A stack trace excerpt is below. I've seen problem reports for this NullPointerException on subselect queries, but our situation does not include subselects. We had other examples of "join fetch" that did not have problems, so I was able to narrow down the problem to the following situation:
- The query was joining a parent and child table using "join fetch" - L2 caching was turned on for both parent and child. - We used addResult to add the child table row to the result set, so we could validate the contents.
We got around this problem by removing the "fetch". This was acceptable for our situation but other applications' mileage may vary.
Caused by: java.lang.NullPointerException at org.hibernate.engine.loading.CollectionLoadContext.addCollectionToCache(CollectionLoadContext.java:298) at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:256) at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:222) at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:195) at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:877) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:865) at org.hibernate.loader.Loader.doQuery(Loader.java:729) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java :236) at org.hibernate.loader.Loader.doList(Loader.java:2220) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:912) 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)
|