List of usage examples for org.hibernate.collection.internal AbstractPersistentCollection getStoredSnapshot
@Override
public final Serializable getStoredSnapshot()
From source file:mojo.core.util.XHCollectionConverter.java
License:Open Source License
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
logger.debug("### Hibernate collection");
if (Hibernate.isInitialized(source)) {
logger.debug("### Unwrapping value");
AbstractPersistentCollection proxy = (AbstractPersistentCollection) source;
Object collection = proxy.getStoredSnapshot();
// Hibernate Set snapshots are HashMaps
logger.debug("### Unwrapped value class: " + collection.getClass());
if (proxy instanceof PersistentSortedSet) {
collection = new TreeSet(((HashMap) collection).values());
} else if (proxy instanceof PersistentSet) {
collection = new HashSet(((HashMap) collection).values());
}/* w w w . j ava 2s .c om*/
context.convertAnother(collection);
}
}