/** * Check whether a named attribute on a given entity with a given mapping * has been loaded. * * This method will check the valueholder or indirect collection for LAZY * ForeignReferenceMappings to see if has been instantiated and otherwise * check the fetch group. * * @param entity * @param attributeName * @param mapping * @return */ public static boolean isLoaded(Object entity, String attributeName, DatabaseMapping mapping) { if (mapping.isForeignReferenceMapping()) { if (((ForeignReferenceMapping) mapping).isLazy()) { Object value = mapping.getAttributeValueFromObject(entity); IndirectionPolicy policy = ((ForeignReferenceMapping) mapping).getIndirectionPolicy(); return policy.objectIsInstantiated(value); } } if (entity instanceof FetchGroupTracker) { return ((FetchGroupTracker) entity)._persistence_isAttributeFetched(attributeName); } else { return true; } }