use of org.eclipse.persistence.descriptors.FetchGroupManager in project eclipselink by eclipse-ee4j.
the class FetchGroupMetadata method process.
/**
* INTERNAL:
*/
public void process(ClassAccessor accessor) {
MetadataDescriptor descriptor = accessor.getDescriptor();
FetchGroupManager fetchGroupManager;
if (descriptor.getClassDescriptor().hasFetchGroupManager()) {
fetchGroupManager = descriptor.getClassDescriptor().getFetchGroupManager();
} else {
fetchGroupManager = new FetchGroupManager();
descriptor.getClassDescriptor().setFetchGroupManager(fetchGroupManager);
}
if (fetchGroupManager.hasFetchGroup(m_name)) {
// We must be adding a fetch group from a mapped superclass.
// Entity fetch groups are added first followed by those from
// mapped superclasses. So if one already exists we need to ignore
// it.
getLogger().logConfigMessage(MetadataLogger.IGNORE_MAPPED_SUPERCLASS_FETCH_GROUP, descriptor.getJavaClass(), accessor.getJavaClass(), m_name);
} else {
FetchGroup fetchGroup = new FetchGroup();
// Process the name of the fetch group.
fetchGroup.setName(m_name);
// Process all the attributes of the fetch group.
for (FetchAttributeMetadata fetchAttribute : m_fetchAttributes) {
fetchGroup.addAttribute(fetchAttribute.getName());
}
fetchGroupManager.addFetchGroup(fetchGroup);
}
}
use of org.eclipse.persistence.descriptors.FetchGroupManager in project eclipselink by eclipse-ee4j.
the class PersistenceContext method wrap.
/**
* Make adjustments to an unmarshalled entity based on what is found in the weaved fields
*/
protected Object wrap(Object entity) {
if ((entity != null) && (PersistenceWeavedRest.class.isAssignableFrom(entity.getClass()))) {
if (!doesExist(null, entity)) {
return entity;
}
ClassDescriptor descriptor = getJAXBDescriptorForClass(entity.getClass());
if (entity instanceof FetchGroupTracker) {
FetchGroup fetchGroup = new FetchGroup();
for (DatabaseMapping mapping : descriptor.getMappings()) {
if (!(mapping instanceof XMLInverseReferenceMapping)) {
fetchGroup.addAttribute(mapping.getAttributeName());
}
}
(new FetchGroupManager()).setObjectFetchGroup(entity, fetchGroup, null);
((FetchGroupTracker) entity)._persistence_setSession(JpaHelper.getDatabaseSession(getEmf()));
} else if (descriptor.hasRelationships()) {
for (DatabaseMapping mapping : descriptor.getMappings()) {
if (mapping instanceof XMLInverseReferenceMapping) {
// we require Fetch groups to handle relationships
JPARSLogger.error(getSessionLog(), "weaving_required_for_relationships", new Object[] {});
throw JPARSException.invalidConfiguration();
}
}
}
}
return entity;
}
Aggregations