I am having a similar problem to the one listed above using hibernate 2.0.3. The main difference being that I am performing an update via session.saveOrUpdate. If I change my mapping to cascade="all" the update succeeds.
Code:
<bag name="categoryList" lazy="true" inverse="true" cascade="all-delete-orphan">
Using step-through debugging, it appears that this call in SessionImpl getOrphans:
Code:
CollectionEntry ce = getCollectionEntry(coll); // SessionImpl.java:2873
returns a null ce (the child collection is not found) and thus the next line:
Code:
return ce.isNew() ? EMPTY : coll.getOrphans( ce.getSnapshot() ); // SessionImpl.java:2874
yields the NullPointerException.
here's the relevant stack trace:
Code:
java.lang.NullPointerException
at net.sf.hibernate.impl.SessionImpl.getOrphans(SessionImpl.java:2874)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:305)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:341)
at net.sf.hibernate.impl.SessionImpl.preFlushEntities(SessionImpl.java:2285)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2015)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2004)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:57)
at com.mandaladesigns.apps.commerce.services.hibernate.HibernatePersistenceServiceImpl.update(HibernatePersistenceServiceImpl.java:58)
Any suggestions on next steps?
Thanks,
Jonathan.