Thanks!
This seems to work as well:
Code:
if (hydratedObject instanceof PersistentCollection) {
// iterate the entries! avoids lazy loading.
try {
Iterator iter = ((PersistentCollection)hydratedObject).entries();
while (iter.hasNext()) {
Object o = (Object) iter.next();
state.add(XmlRpcHelper.dehydrate(o, context));
}
} catch (NullPointerException ex) {
// the collection is totally uninitialized!
// TODO: is there a way to CHECK?!
log.warn("PersistentCollection.entries threw NPE; assuming empty.");
// and do nothing! we WANT an empty collection here.
}
Not as elegant, though :-)
Also, is it possible that a collection could be initialized but only *partially* lazy-loaded, and that in that case isInitialized() would return true but iterating would still force further lazy loading (which, as I said, is not what I want)? I *know* that calling "entries()" will never force any lazy loading.
Cheers!
Rob