views:

118

answers:

1

My DAO detaches and then caches certain objects, and it may retrieve them with different fetch groups. Depending on which fetch group was used to retrieve the object, certain fields of that object may be available, or not. I would like to be able to test whether a given field on that object was loaded or not, but I can't simply check whether the field is null because that results in a "JDODetachedFieldAccessException" which demands that I either not access the field or detach the field first.

I could always catch that exception, but that doesn't smell right. So, does anyone know whether its possible to check if the field was detached?

A: 

http://www.datanucleus.org/products/accessplatform/jdo/attach_detach.html

DataNucleus
Specifically, this:String[] loadedFieldNames = NucleusJDOHelper.getDetachedObjectLoadedFields(obj, pm);String[] dirtyFieldNames = NucleusJDOHelper.getDetachedObjectDirtyFields(obj, pm);I've read the docs but somehow missed that, only human!
tempy