@Override public Set<String> getAttributes() { return wrappedFetchGroup.getAttributes(); }
/** * INTERNAL: * Return true if this fetch group is a super-set of the passed in fetch group. */ public boolean isSupersetOf(FetchGroup anotherGroup) { return (anotherGroup != null) && ((this == anotherGroup) || getAttributes().containsAll(anotherGroup.getAttributes())); } }
/** * Return if the attribute is defined in the group. */ public boolean containsAttribute(String attribute) { return getAttributes().contains(attribute); }
/** * INTERNAL: * Return if fetch group attribute. */ public boolean isFetchGroupAttribute(String attributeName) { if (getFetchGroup() == null) { //every attribute is fetched already return true; } return getFetchGroup().getAttributes().contains(attributeName); }
/** * Revert the clones' unfetched attributes, and leave fetched ones intact. */ private void revertDataIntoUnfetchedAttributesOfClones(Object cachedObject, Object workingClone, Object backupClone, FetchGroup fetchGroupInObject, FetchGroup fetchGroupInClone, UnitOfWorkImpl uow) { Vector mappings = descriptor.getMappings(); // Fetched attributes set in working clone. Set fetchedAttributesClone = fetchGroupInClone.getAttributes(); // Fetched attributes set in cached object. Set fetchedAttributesCached = null; if (fetchGroupInObject != null) { fetchedAttributesCached = fetchGroupInObject.getAttributes(); } int size = mappings.size(); for (int index = 0; index < size; index++) { DatabaseMapping mapping = (DatabaseMapping)mappings.get(index); String attributeName = mapping.getAttributeName(); // Only revert the attribute which is fetched by the cached object, but not fetched by the clone. if (((fetchedAttributesCached == null) || fetchedAttributesCached.contains(attributeName)) && (!fetchedAttributesClone.contains(attributeName))) { mapping.buildClone(cachedObject, workingClone, uow); if (workingClone != backupClone) { mapping.buildClone(workingClone, backupClone, uow); } } } }
protected void addFetchGroupLines(NonreflectiveMethodDefinition method, FetchGroup fetchGroup, String fetchGroupIdentifier) { Iterator attributeIter = fetchGroup.getAttributes().iterator(); method.addLine("FetchGroup " + fetchGroupIdentifier + " = new FetchGroup();"); if (!fetchGroup.getName().equals("")) { method.addLine(fetchGroupIdentifier + ".setName(\"" + fetchGroup.getName() + "\");"); } while (attributeIter.hasNext()) { String attribute = (String)attributeIter.next(); method.addLine(fetchGroupIdentifier + ".addAttribute(\"" + attribute + "\");"); } }
/** * Refresh the fetch group data into the working and backup clones. * This is called if refresh is enforced */ private void refreshFetchGroupIntoClones(Object cachedObject, Object workingClone, Object backupClone, FetchGroup fetchGroupInObject, FetchGroup fetchGroupInClone, UnitOfWorkImpl uow) { Vector mappings = descriptor.getMappings(); boolean isObjectPartial = (fetchGroupInObject != null); Set fetchedAttributes = isObjectPartial ? fetchGroupInObject.getAttributes() : null; int size = mappings.size(); for (int index = 0; index < size; index++) { DatabaseMapping mapping = (DatabaseMapping)mappings.get(index); if ((!isObjectPartial) || ((fetchedAttributes != null) && fetchedAttributes.contains(mapping.getAttributeName()))) { // Only refresh the fetched attributes into clones. mapping.buildClone(cachedObject, workingClone, uow); if (workingClone != backupClone) { mapping.buildClone(workingClone, backupClone, uow); } } } }
/** * INTERNAL: * Union two fetch groups. */ public FetchGroup unionFetchGroups(FetchGroup first, FetchGroup second) { if ((first == null) || (second == null)) { return null; } //return the superset if applied if (first.isSupersetOf(second)) { return first; } else if (second.isSupersetOf(first)) { return second; } //otherwise, union two fetch groups StringBuffer unionGroupName = new StringBuffer(first.getName()); unionGroupName.append("_"); unionGroupName.append(second.getName()); FetchGroup unionFetchGroup = new FetchGroup(unionGroupName.toString()); unionFetchGroup.addAttributes(first.getAttributes()); unionFetchGroup.addAttributes(second.getAttributes()); return unionFetchGroup; }
Set fetchedFields = new HashSet(getFetchGroup().getAttributes().size() + 2); for (Iterator iterator = getFetchGroup().getAttributes().iterator(); iterator.hasNext();) { String attribute = (String)iterator.next(); DatabaseMapping mapping = getDescriptor().getObjectBuilder().getMappingForAttributeName(attribute); Vector fields = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(getFetchGroup().getAttributes().size() + 2); for (Iterator iterator = getDescriptor().getFields().iterator(); iterator.hasNext();) { DatabaseField field = (DatabaseField)iterator.next();