Hi all,
Thanks all for this great solution !
I was playing around with this fix and I was having the classic hibernate exceptions telling there is no session attached any more.
The culprit was in HibernateCollectionConverterNEW.java when at the beginning of the marshal method, col.forceInitialization() is called.
I added a simple fix which will write null if the collection is null and won't call col.forceInitialization() is the session is null or not connected:
if (source instanceof AbstractPersistentCollection) {
AbstractPersistentCollection col = (AbstractPersistentCollection) source;
if ((col.getSession() != null) && col.getSession().isConnected())
{
col.forceInitialization();
}
collection = col.getStoredSnapshot();
} else if (source instanceof PersistentCollection)
{
PersistentCollection col = (PersistentCollection) source;
col.forceInitialization();
// ToDo ES: collection = col.getCollectionSnapshot().getSnapshot();
collection = col.getStoredSnapshot();
}
if (collection == null)
{
NULL_CONVERTER.marshal(collection, writer, context);
return;
}
...
converter