This is the exception I met:
7:32:31.334 3303 07:32:31,333 ERROR AssertionFailure:45 - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
07:32:31.334 3304 org.hibernate.AssertionFailure: force initialize loading collection
07:32:31.334 3305 at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:471)
07:32:31.334 3306 at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:900)
07:32:31.334 3307 at org.hibernate.event.def.DefaultLoadEventListener.assembleCacheEntry(DefaultLoadEventListener.java:690)
07:32:31.334 3308 at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:605)
07:32:31.334 3309 at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:459)
07:32:31.334 3310 at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
07:32:31.334 3311 at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
07:32:31.334 3312 at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
07:32:31.334 3313 at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
07:32:31.334 3314 at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
07:32:31.334 3315 at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
07:32:31.334 3316 at org.hibernate.type.EntityType.resolve(EntityType.java:438)
07:32:31.334 3317 at org.hibernate.type.OneToOneType.assemble(OneToOneType.java:157)
07:32:31.334 3318 at org.hibernate.type.TypeHelper.assemble(TypeHelper.java:114)
07:32:31.334 3319 at org.hibernate.cache.entry.CacheEntry.assemble(CacheEntry.java:117)
07:32:31.334 3320 at org.hibernate.cache.entry.CacheEntry.assemble(CacheEntry.java:104)
07:32:31.334 3321 at org.hibernate.event.def.DefaultLoadEventListener.assembleCacheEntry(DefaultLoadEventListener.java:651)
07:32:31.334 3322 at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:605)
07:32:31.334 3323 at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:459)
07:32:31.334 3324 at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
07:32:31.334 3325 at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
07:32:31.334 3326 at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
07:32:31.334 3327 at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
07:32:31.334 3328 at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
07:32:31.334 3329 at currenex.share.wmx.database.dao.impl.CurrencyDAOImpl.findById(CurrencyDAOImpl.java:82)
07:32:31.334 3330 at
In the code, every time to query data via session.get(), I will new open a session and after query finishes I will close the session.
And this exception happened occasionally.
I have debug the source code of hibernate. And found no clue.
BTW, I am using hiberante 3 in my project, due to this is a very very old project. Not have a chance to upgrade hibernate