/** * INTERNAL: * Used to retrieve the EntityFetchGroup for this FetchGroup * @return the entityFetchGroup */ public EntityFetchGroup getEntityFetchGroup(FetchGroupManager fetchGroupManager) { if (this.entityFetchGroup == null){ this.entityFetchGroup = fetchGroupManager.getEntityFetchGroup(this.getAttributeNames()); } return entityFetchGroup; }
/** * INTERNAL: * Used to retrieve the EntityFetchGroup for this FetchGroup * @return the entityFetchGroup */ public EntityFetchGroup getEntityFetchGroup(FetchGroupManager fetchGroupManager) { if (this.entityFetchGroup == null){ this.entityFetchGroup = fetchGroupManager.getEntityFetchGroup(this.getAttributeNames()); } return entityFetchGroup; }
/** * INTERNAL: * Return FetchGroup held by the object. */ public EntityFetchGroup getObjectEntityFetchGroup(Object domainObject) { if (domainObject != null) { FetchGroup fetchGroup = ((FetchGroupTracker)domainObject)._persistence_getFetchGroup(); if(fetchGroup != null) { if(fetchGroup.isEntityFetchGroup()) { return (EntityFetchGroup)fetchGroup; } return getEntityFetchGroup(fetchGroup); } } return null; }
/** * INTERNAL: * Return FetchGroup held by the object. */ public EntityFetchGroup getObjectEntityFetchGroup(Object domainObject) { if (domainObject != null) { FetchGroup fetchGroup = ((FetchGroupTracker)domainObject)._persistence_getFetchGroup(); if(fetchGroup != null) { if(fetchGroup.isEntityFetchGroup()) { return (EntityFetchGroup)fetchGroup; } return getEntityFetchGroup(fetchGroup); } } return null; }
/** * INTERNAL: * Union two fetch groups as EntityFetchGroups. * Ignores all nested attributes. */ public EntityFetchGroup flatUnionFetchGroups(FetchGroup first, FetchGroup second, boolean shouldClone) { if ((first == null) || (second == null)) { return null; } //return the superset if applied if (first == second) { return getEntityFetchGroup(first); } Set<String> unionAttributeNames = new HashSet(); unionAttributeNames.addAll(first.getAttributeNames()); unionAttributeNames.addAll(second.getAttributeNames()); EntityFetchGroup newGroup = getEntityFetchGroup(unionAttributeNames); if (shouldClone){ newGroup = (EntityFetchGroup) newGroup.clone(); newGroup.setRootEntity(second.getRootEntity()); } return newGroup; }
/** * INTERNAL: * Union two fetch groups as EntityFetchGroups. * Ignores all nested attributes. */ public EntityFetchGroup flatUnionFetchGroups(FetchGroup first, FetchGroup second, boolean shouldClone) { if ((first == null) || (second == null)) { return null; } //return the superset if applied if (first == second) { return getEntityFetchGroup(first); } Set<String> unionAttributeNames = new HashSet(); unionAttributeNames.addAll(first.getAttributeNames()); unionAttributeNames.addAll(second.getAttributeNames()); EntityFetchGroup newGroup = getEntityFetchGroup(unionAttributeNames); if (shouldClone){ newGroup = (EntityFetchGroup) newGroup.clone(); newGroup.setRootEntity(second.getRootEntity()); } return newGroup; }
/** * 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 == second || first.isSupersetOf(second)) { return first; } else if (second.isSupersetOf(first)) { return second; } Set<String> unionAttributeNames = new HashSet(); unionAttributeNames.addAll(first.getAttributeNames()); unionAttributeNames.addAll(second.getAttributeNames()); return getEntityFetchGroup(unionAttributeNames); }
/** * 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 == second || first.isSupersetOf(second)) { return first; } else if (second.isSupersetOf(first)) { return second; } Set<String> unionAttributeNames = new HashSet(); unionAttributeNames.addAll(first.getAttributeNames()); unionAttributeNames.addAll(second.getAttributeNames()); return getEntityFetchGroup(unionAttributeNames); }
this.defaultEntityFetchGroup = this.getEntityFetchGroup(newDefaultFetchGroup); } else { this.defaultEntityFetchGroup = null;
this.defaultEntityFetchGroup = this.getEntityFetchGroup(newDefaultFetchGroup); } else { this.defaultEntityFetchGroup = null;
protected void initNonReferenceEntityFetchGroup() { FetchGroup nonReferenceFetchGroup = new FetchGroup(); for (DatabaseMapping mapping : getDescriptor().getMappings()) { if(!mapping.isForeignReferenceMapping()) { String name = mapping.getAttributeName(); if(this.defaultEntityFetchGroup == null || this.defaultEntityFetchGroup.containsAttribute(name)) { nonReferenceFetchGroup.addAttribute(name); } } } this.addMinimalFetchGroup(nonReferenceFetchGroup); this.nonReferenceEntityFetchGroup = getEntityFetchGroup(nonReferenceFetchGroup); }
protected void initNonReferenceEntityFetchGroup() { FetchGroup nonReferenceFetchGroup = new FetchGroup(); for (DatabaseMapping mapping : getDescriptor().getMappings()) { if(!mapping.isForeignReferenceMapping()) { String name = mapping.getAttributeName(); if(this.defaultEntityFetchGroup == null || this.defaultEntityFetchGroup.containsAttribute(name)) { nonReferenceFetchGroup.addAttribute(name); } } } this.addMinimalFetchGroup(nonReferenceFetchGroup); this.nonReferenceEntityFetchGroup = getEntityFetchGroup(nonReferenceFetchGroup); }
FetchGroup fetchGroup = it.next(); prepareAndVerify(fetchGroup); getEntityFetchGroup(fetchGroup); this.defaultEntityFetchGroup = getEntityFetchGroup(this.defaultFetchGroup);
FetchGroup fetchGroup = it.next(); prepareAndVerify(fetchGroup); getEntityFetchGroup(fetchGroup); this.defaultEntityFetchGroup = getEntityFetchGroup(this.defaultFetchGroup);
/** * INTERNAL: * Set fetch group into the object. */ public void setObjectFetchGroup(Object source, FetchGroup fetchGroup, AbstractSession session) { FetchGroupTracker tracker = (FetchGroupTracker)source; if(fetchGroup == null) { tracker._persistence_setFetchGroup(null); tracker._persistence_setSession(null); } else { if(fetchGroup.isEntityFetchGroup()) { // it's EntityFetchGroup - just set it tracker._persistence_setFetchGroup(fetchGroup); tracker._persistence_setSession(session); } else { EntityFetchGroup entityFetchGroup = this.getEntityFetchGroup(fetchGroup); if(entityFetchGroup != null) { tracker._persistence_setFetchGroup(entityFetchGroup); tracker._persistence_setSession(session); } else { tracker._persistence_setFetchGroup(null); tracker._persistence_setSession(null); } } } }
/** * INTERNAL: * Set fetch group into the object. */ public void setObjectFetchGroup(Object source, FetchGroup fetchGroup, AbstractSession session) { FetchGroupTracker tracker = (FetchGroupTracker)source; if(fetchGroup == null) { tracker._persistence_setFetchGroup(null); tracker._persistence_setSession(null); } else { if(fetchGroup.isEntityFetchGroup()) { // it's EntityFetchGroup - just set it tracker._persistence_setFetchGroup(fetchGroup); tracker._persistence_setSession(session); } else { EntityFetchGroup entityFetchGroup = this.getEntityFetchGroup(fetchGroup); if(entityFetchGroup != null) { tracker._persistence_setFetchGroup(entityFetchGroup); tracker._persistence_setSession(session); } else { tracker._persistence_setFetchGroup(null); tracker._persistence_setSession(null); } } } }
/** * Clean up the cached object data and only revert the fetch group data back to the cached object. */ private void revertFetchGroupData(Object domainObject, ClassDescriptor concreteDescriptor, CacheKey cacheKey, ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, AbstractSession session, boolean targetIsProtected) { FetchGroup fetchGroup = query.getExecutionFetchGroup(concreteDescriptor); FetchGroupManager fetchGroupManager = concreteDescriptor.getFetchGroupManager(); //the cached object is either invalidated, or staled as the version is newer, or a refresh is explicitly set on the query. //clean all data of the cache object. fetchGroupManager.reset(domainObject); //set fetch group reference to the cached object fetchGroupManager.setObjectFetchGroup(domainObject, fetchGroupManager.getEntityFetchGroup(fetchGroup), session); // Bug 276362 - set the CacheKey's read time (to re-validate the CacheKey) before buildAttributesIntoObject is called cacheKey.setReadTime(query.getExecutionTime()); //read in the fetch group data only concreteDescriptor.getObjectBuilder().buildAttributesIntoObject(domainObject, cacheKey, databaseRow, query, joinManager, fetchGroup, false, session); //set refresh on fetch group fetchGroupManager.setRefreshOnFetchGroupToObject(domainObject, (query.shouldRefreshIdentityMapResult() || concreteDescriptor.shouldAlwaysRefreshCache())); //set query id to prevent infinite recursion on refresh object cascade all cacheKey.setLastUpdatedQueryId(query.getQueryId()); //register the object into the IM and set the write lock object if applied. if (concreteDescriptor.usesOptimisticLocking()) { OptimisticLockingPolicy policy = concreteDescriptor.getOptimisticLockingPolicy(); cacheKey.setWriteLockValue(policy.getValueToPutInCache(databaseRow, session)); } }
/** * Clean up the cached object data and only revert the fetch group data back to the cached object. */ private void revertFetchGroupData(Object domainObject, ClassDescriptor concreteDescriptor, CacheKey cacheKey, ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, AbstractSession session, boolean targetIsProtected) { FetchGroup fetchGroup = query.getExecutionFetchGroup(concreteDescriptor); FetchGroupManager fetchGroupManager = concreteDescriptor.getFetchGroupManager(); //the cached object is either invalidated, or staled as the version is newer, or a refresh is explicitly set on the query. //clean all data of the cache object. fetchGroupManager.reset(domainObject); //set fetch group reference to the cached object fetchGroupManager.setObjectFetchGroup(domainObject, fetchGroupManager.getEntityFetchGroup(fetchGroup), session); // Bug 276362 - set the CacheKey's read time (to re-validate the CacheKey) before buildAttributesIntoObject is called cacheKey.setReadTime(query.getExecutionTime()); //read in the fetch group data only concreteDescriptor.getObjectBuilder().buildAttributesIntoObject(domainObject, cacheKey, databaseRow, query, joinManager, fetchGroup, false, session); //set refresh on fetch group fetchGroupManager.setRefreshOnFetchGroupToObject(domainObject, (query.shouldRefreshIdentityMapResult() || concreteDescriptor.shouldAlwaysRefreshCache())); //set query id to prevent infinite recursion on refresh object cascade all cacheKey.setLastUpdatedQueryId(query.getQueryId()); //register the object into the IM and set the write lock object if applied. if (concreteDescriptor.usesOptimisticLocking()) { OptimisticLockingPolicy policy = concreteDescriptor.getOptimisticLockingPolicy(); cacheKey.setWriteLockValue(policy.getValueToPutInCache(databaseRow, session)); } }
return getEntityFetchGroup(nonReferenceFetchGroup);
return getEntityFetchGroup(nonReferenceFetchGroup);