/** * Instantiate the object by executing the query on the session. */ protected Object instantiate(AbstractSession session) throws DatabaseException { if (session == null) { throw ValidationException.instantiatingValueholderWithNullSession(); } if (this.query.isObjectBuildingQuery() && ((ObjectBuildingQuery)this.query).shouldRefreshIdentityMapResult()){ this.refreshCascade = ((ObjectBuildingQuery)this.query).getCascadePolicy(); } Object result = session.executeQuery(getQuery(), getRow()); // Bug 489898 - ensure that the query's session is dereferenced, post-execution getQuery().setSession(null); return result; }
Object attributeValue = getAttributeValueFromObject(cached); Integer refreshCascade = null; if (query != null && query.shouldRefreshIdentityMapResult()){ refreshCascade = query.getCascadePolicy(); if (executionSession.isUnitOfWork() && query.shouldRefreshIdentityMapResult()){ oldAttribute = this.getAttributeValueFromObject(object); throw exception; if (executionSession.isUnitOfWork() && query.shouldRefreshIdentityMapResult()){ if (this.indirectionPolicy.objectIsInstantiatedOrChanged(oldAttribute)){ this.indirectionPolicy.instantiateObject(object, attributeValue);
Object attributeValue = getAttributeValueFromObject(cached); Integer refreshCascade = null; if (query != null && query.shouldRefreshIdentityMapResult()){ refreshCascade = query.getCascadePolicy(); if (executionSession.isUnitOfWork() && query.shouldRefreshIdentityMapResult()){ oldAttribute = this.getAttributeValueFromObject(object); throw exception; if (executionSession.isUnitOfWork() && query.shouldRefreshIdentityMapResult()){ if (this.indirectionPolicy.objectIsInstantiatedOrChanged(oldAttribute)){ this.indirectionPolicy.instantiateObject(object, attributeValue);
if (sourceQuery != null && sourceQuery.isObjectBuildingQuery() && sourceQuery.shouldRefreshIdentityMapResult()) { refreshCascade = sourceQuery.getCascadePolicy(); if (executionSession.isUnitOfWork() && sourceQuery.shouldRefreshIdentityMapResult() || databaseRow.hasSopObject()){
if (sourceQuery != null && sourceQuery.isObjectBuildingQuery() && sourceQuery.shouldRefreshIdentityMapResult()) { refreshCascade = sourceQuery.getCascadePolicy(); if (executionSession.isUnitOfWork() && sourceQuery.shouldRefreshIdentityMapResult() || databaseRow.hasSopObject()){
/** * Post process the object once it is registered in the unit of work. */ public void postRegisterIndividualResult(Object clone, Object original, Object primaryKey, UnitOfWorkImpl unitOfWork, JoinedAttributeManager joinManager, ClassDescriptor concreteDescriptor) { // Check for refreshing, require to revert in the unit of work to accomplish a refresh. if (shouldRefreshIdentityMapResult()) { if (shouldCascadeAllParts()) { unitOfWork.mergeClone(original, MergeManager.CASCADE_ALL_PARTS, true); } else if (shouldCascadePrivateParts()) { unitOfWork.mergeClone(original, MergeManager.CASCADE_PRIVATE_PARTS, true); } else if (shouldCascadeByMapping()) { unitOfWork.mergeClone(original, MergeManager.CASCADE_BY_MAPPING, true); } else if (!shouldCascadeParts()) { unitOfWork.mergeClone(original, MergeManager.NO_CASCADE, true); } } //bug 6130550: trigger indirection on the clone where required due to fetch joins on the query if (joinManager != null && joinManager.hasJoinedAttributeExpressions()) { triggerJoinExpressions(unitOfWork, joinManager, clone, concreteDescriptor); } }
/** * Post process the object once it is registered in the unit of work. */ public void postRegisterIndividualResult(Object clone, Object original, Object primaryKey, UnitOfWorkImpl unitOfWork, JoinedAttributeManager joinManager, ClassDescriptor concreteDescriptor) { // Check for refreshing, require to revert in the unit of work to accomplish a refresh. if (shouldRefreshIdentityMapResult()) { if (shouldCascadeAllParts()) { unitOfWork.mergeClone(original, MergeManager.CASCADE_ALL_PARTS, true); } else if (shouldCascadePrivateParts()) { unitOfWork.mergeClone(original, MergeManager.CASCADE_PRIVATE_PARTS, true); } else if (shouldCascadeByMapping()) { unitOfWork.mergeClone(original, MergeManager.CASCADE_BY_MAPPING, true); } else if (!shouldCascadeParts()) { unitOfWork.mergeClone(original, MergeManager.NO_CASCADE, true); } } //bug 6130550: trigger indirection on the clone where required due to fetch joins on the query if (joinManager != null && joinManager.hasJoinedAttributeExpressions()) { triggerJoinExpressions(unitOfWork, joinManager, clone, concreteDescriptor); } }
((ObjectLevelReadQuery)targetQuery).setShouldRefreshIdentityMapResult(query.shouldRefreshIdentityMapResult()); targetQuery.setCascadePolicy(query.getCascadePolicy());
Object attributeValue = valueFromRow(databaseRow, joinManager, sourceQuery, sharedCacheKey, executionSession, true, wasCacheUsed); Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, null, sharedCacheKey,clone, null, unitOfWork, !wasCacheUsed[0]);// building clone directly from row. if (executionSession.isUnitOfWork() && sourceQuery.shouldRefreshIdentityMapResult()){
((ObjectLevelReadQuery)targetQuery).setShouldRefreshIdentityMapResult(query.shouldRefreshIdentityMapResult()); targetQuery.setCascadePolicy(query.getCascadePolicy());
Object attributeValue = valueFromRow(databaseRow, joinManager, sourceQuery, sharedCacheKey, executionSession, true, wasCacheUsed); Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, null, sharedCacheKey,clone, null, unitOfWork, !wasCacheUsed[0]);// building clone directly from row. if (executionSession.isUnitOfWork() && sourceQuery.shouldRefreshIdentityMapResult()){
/** * 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)); } }
/** * 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) { //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. concreteDescriptor.getFetchGroupManager().reset(domainObject); //set fetch group reference to the cached object concreteDescriptor.getFetchGroupManager().setObjectFetchGroup(domainObject, query.getFetchGroup(), 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, databaseRow, query, joinManager, false); //set refresh on fetch group concreteDescriptor.getFetchGroupManager().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)); } }
query.setShouldRefreshIdentityMapResult(sourceQuery.shouldRefreshIdentityMapResult()); query.setCascadePolicy(sourceQuery.getCascadePolicy()); query.setShouldMaintainCache(sourceQuery.shouldMaintainCache());
nestedQuery.setRequiresDeferredLocks(sourceQuery.requiresDeferredLocks()); nestedQuery.setPrefetchedCacheKeys(sourceQuery.getPrefetchedCacheKeys()); nestedQuery.setShouldRefreshIdentityMapResult(sourceQuery.shouldRefreshIdentityMapResult()); referenceObject = this.referenceDescriptor.getObjectBuilder().buildObject(nestedQuery, targetRow);
nestedQuery.setRequiresDeferredLocks(sourceQuery.requiresDeferredLocks()); nestedQuery.setPrefetchedCacheKeys(sourceQuery.getPrefetchedCacheKeys()); nestedQuery.setShouldRefreshIdentityMapResult(sourceQuery.shouldRefreshIdentityMapResult()); referenceObject = this.referenceDescriptor.getObjectBuilder().buildObject(nestedQuery, targetRow);
if (sourceQuery != null && sourceQuery.isObjectBuildingQuery() && sourceQuery.shouldRefreshIdentityMapResult()){ refreshCascade = sourceQuery.getCascadePolicy();
if (sourceQuery != null && sourceQuery.isObjectBuildingQuery() && sourceQuery.shouldRefreshIdentityMapResult()){ refreshCascade = sourceQuery.getCascadePolicy();
throw ValidationException.instantiatingValueholderWithNullSession(); if (this.query.isObjectBuildingQuery() && ((ObjectBuildingQuery)this.query).shouldRefreshIdentityMapResult()){ this.refreshCascade = ((ObjectBuildingQuery)this.query).getCascadePolicy();