Hi,

just encountered, that one gets an NPE in
org.hibernate.engine.CollectionLoadContext#addCollectionToCache()
when running the legacy.FumTest#testUnflushedSessionSerialization
with MySQLInnoDBDialect + DefaultHibernateCache:

The ctx lines are:
  s = getSessions().openSession();
  s.setFlushMode(FlushMode.NEVER);
-->  fum = (Fum) s.load( Fum.class, fum.getId() );
  assertTrue("the Fum.friends did not get saved", fum.getFriends().size() == 2);

When loading is done, the correct result gets fetched from the db,
but it seems, that something goes wrong wrt. caching. I fixed, but
I'm not sure, whether it is the right thing, to do it this way...

Any opinions?

Regards,
jens.

fix:
---
hibernate-3.1.3.orig/src/org/hibernate/engine/CollectionLoadContext.java
Mon Mar 20 21:19:36 2006
+++ hibernate-3.1.3/src/org/hibernate/engine/CollectionLoadContext.java
Sat Mar 25 21:14:20 2006
@@ -303,7 +303,18 @@
                final Object version;
                if ( persister.isVersioned() ) {
                        versionComparator =
persister.getOwnerEntityPersister().getVersionType().getComparator();
-                       version = context.getEntry(
                        context.getCollectionOwner(lce.key, 
persister)).getVersion();
+                       EntityEntry e = context.getEntry( 
context.getCollectionOwner(lce.key, persister) );
+                       if (e == null) {
+                               log.error(lce.key + " not found in context - no 
version info");
+                               if (log.isDebugEnabled()) {
+                                       Exception ex = new Exception("no 
version exception");
+                                       ex.fillInStackTrace();
+                                                                               
log.debug("persister.getVersion", ex);
+                               }
+                               version = null;
+                       } else {
+                               version = e.getVersion();
+                       }
                }
                else {
                        version = null;




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to