/** * INTERNAL: * Same functionality as setRealAttributeValueInObject(Object target, Object attributeValue) but allows * overridden behavior for IndirectionPolicies that track changes * @param target * @param attributeValue * @param allowChangeTracking */ public void setRealAttributeValueInObject(Object target, Object attributeValue, boolean allowChangeTracking) { setRealAttributeValueInObject(target, attributeValue); }
/** * INTERNAL: * Clone the attribute from the clone and assign it to the backup. */ public void buildBackupClone(Object clone, Object backup, UnitOfWorkImpl unitOfWork) { Object attributeValue = getAttributeValueFromObject(clone); Object clonedAttributeValue = this.indirectionPolicy.backupCloneAttribute(attributeValue, clone, backup, unitOfWork); setAttributeValueInObject(backup, clonedAttributeValue); }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ protected void mergeClientIntoServerValueHolder(RemoteValueHolder serverValueHolder, MergeManager mergeManager) { serverValueHolder.setMapping(getMapping()); serverValueHolder.setSession(mergeManager.getSession()); if (getMapping().isForeignReferenceMapping()) { ObjectLevelReadQuery query = buildCascadeQuery(mergeManager); serverValueHolder.setQuery(query); } }
refreshCascade = query.getCascadePolicy(); return this.indirectionPolicy.cloneAttribute(attributeValue, cached, parentCacheKey, object, refreshCascade, executionSession, false); return getAttributeValueFromObject(row.getSopObject()); Object attributeValue = this.indirectionPolicy.valueFromMethod(object, row, query.getSession()); Object oldAttribute = null; if (executionSession.isUnitOfWork() && query.shouldRefreshIdentityMapResult()){ if (this.indirectionPolicy.objectIsInstantiatedOrChanged(oldAttribute)){ this.indirectionPolicy.instantiateObject(object, attributeValue);
refreshCascade = sourceQuery.getCascadePolicy(); attributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, parentCacheKey.getObject(), parentCacheKey, targetObject, refreshCascade, executionSession, false); Object oldAttribute = this.getAttributeValueFromObject(targetObject); if (wasAttributeValueFullyBuilt && this.indirectionPolicy.objectIsInstantiatedOrChanged(oldAttribute)){ this.indirectionPolicy.instantiateObject(targetObject, attributeValue); this.indirectionPolicy.setSourceObject(parentCacheKey.getObject(), attributeValue);
public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager, AbstractSession targetSession) { if (this.descriptor.getCachePolicy().isProtectedIsolation()&& !this.isCacheable && !targetSession.isProtectedSession()){ setAttributeValueInObject(target, this.indirectionPolicy.buildIndirectObject(new ValueHolder(null))); return; setAttributeValueInObject(target, this.indirectionPolicy.getOriginalIndirectionObject(getAttributeValueFromObject(source), targetSession)); return; } else { this.indirectionPolicy.reset(target); refreshCascade = selectionQuery.getCascadePolicy(); Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, source, null, target, refreshCascade, mergeManager.getSession(), false); // building clone from an original not a row. setAttributeValueInObject(target, clonedAttributeValue);
Boolean[] wasCacheUsed = new Boolean[]{Boolean.FALSE}; 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()){ Object oldAttribute = this.getAttributeValueFromObject(clone); if (wasAttributeValueFullyBuilt && this.indirectionPolicy.objectIsInstantiatedOrChanged(oldAttribute)){ this.indirectionPolicy.instantiateObject(clone, clonedAttributeValue); this.indirectionPolicy.instantiateObject(clone, clonedAttributeValue);
AbstractRecord referenceRow = this.indirectionPolicy.extractReferenceRow(attributeValue); if (referenceRow == null) {
/** * INTERNAL: * Record deletion dependencies for foreign key constraints. * This is used during deletion to resolve deletion cycles. */ @Override public void earlyPreDelete(DeleteObjectQuery query, Object object) { AbstractSession session = query.getSession(); // Avoid instantiating objects. Object attributeValue = getAttributeValueFromObject(object); Object targetObject = null; if (!this.indirectionPolicy.objectIsInstantiated(attributeValue) && !this.indirectionPolicy.objectIsEasilyInstantiated(attributeValue)) { AbstractRecord referenceRow = this.indirectionPolicy.extractReferenceRow(attributeValue); targetObject = this.selectionQuery.checkEarlyReturn(session, referenceRow); } else { targetObject = getRealAttributeValueFromAttribute(attributeValue, object, session); } UnitOfWorkImpl unitOfWork = (UnitOfWorkImpl)session; if ((targetObject != null) && unitOfWork.getDeletedObjects().containsKey(targetObject)) { unitOfWork.addDeletionDependency(targetObject, object); } }
/** * INTERNAL: * Reduce casting clutter.... */ protected AbstractTransformationMapping getTransformationMapping() { return (AbstractTransformationMapping)this.getMapping(); }
/** * INTERNAL: * Clone the attribute from the original and assign it to the clone. */ public void buildClone(Object original, Object clone, UnitOfWorkImpl unitOfWork) { Object attributeValue = getAttributeValueFromObject(original); Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, original, clone, unitOfWork, false); // building clone from an original not a row. //GFBug#404 - fix moved to ObjectBuildingQuery.registerIndividualResult setAttributeValueInObject(clone, clonedAttributeValue); }
public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager, AbstractSession targetSession) { if (this.descriptor.getCachePolicy().isProtectedIsolation() && !this.isCacheable && !targetSession.isProtectedSession()){ setAttributeValueInObject(target, this.indirectionPolicy.buildIndirectObject(new ValueHolder(null))); return; setAttributeValueInObject(target, this.indirectionPolicy.getOriginalIndirectionObject(getAttributeValueFromObject(source), targetSession)); return; Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, source, null, target, null, mergeManager.getSession(), false); // building clone from an original not a row. setAttributeValueInObject(target, clonedAttributeValue);
/** * INTERNAL: * A combination of readFromRowIntoObject and buildClone. * <p> * buildClone assumes the attribute value exists on the original and can * simply be copied. * <p> * readFromRowIntoObject assumes that one is building an original. * <p> * Both of the above assumptions are false in this method, and actually * attempts to do both at the same time. * <p> * Extract value from the row and set the attribute to this value in the * working copy clone. * In order to bypass the shared cache when in transaction a UnitOfWork must * be able to populate working copies directly from the row. */ public void buildCloneFromRow(AbstractRecord databaseRow, JoinedAttributeManager joinManager, Object clone, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { Object attributeValue = valueFromRow(databaseRow, joinManager, sourceQuery, executionSession); Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, null,// no original clone, unitOfWork, true);// building clone directly from row. setAttributeValueInObject(clone, clonedAttributeValue); if(isExtendingPessimisticLockScope(sourceQuery) && extendPessimisticLockScope == ExtendPessimisticLockScope.TARGET_QUERY) { // need to instantiate to extended the lock beyond the source object table(s). this.indirectionPolicy.instantiateObject(clone, clonedAttributeValue); } }
/** * INTERNAL: * An object has been serialized from the server to the client. * Replace the transient attributes of the remote value holders * with client-side objects. */ @Override public void fixObjectReferences(Object object, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, DistributedSession session) { this.indirectionPolicy.fixObjectReferences(object, objectDescriptors, processedObjects, query, session); }
/** * INTERNAL: * Extract the reference pk for rvh usage in remote model. */ public Object extractPrimaryKeysForReferenceObject(Object domainObject, AbstractSession session) { return this.indirectionPolicy.extractPrimaryKeyForReferenceObject(getAttributeValueFromObject(domainObject), session); }
/** * INTERNAL: * The mapping clones itself to create deep copy. */ @Override public Object clone() { AbstractTransformationMapping clone = (AbstractTransformationMapping)super.clone(); clone.setFieldToTransformers(new ArrayList(this.fieldToTransformers.size())); for (Object[] pair : this.fieldToTransformers) { Object[] transformation = new Object[2]; transformation[0] = pair[0]; transformation[1] = pair[1]; clone.getFieldToTransformers().add(transformation); } clone.setIndirectionPolicy((IndirectionPolicy)indirectionPolicy.clone()); return clone; }
/** * INTERNAL * Return true if the refresh should refresh on this mapping or not. */ protected ReadObjectQuery buildCascadeQuery(MergeManager mergeManager) { ReadObjectQuery cascadeQuery = new ReadObjectQuery(); if (mergeManager.shouldCascadeAllParts()) { cascadeQuery.cascadeAllParts(); cascadeQuery.refreshIdentityMapResult(); } if (mergeManager.shouldCascadePrivateParts() && getForeignReferenceMapping().isPrivateOwned()) { cascadeQuery.cascadePrivateParts(); cascadeQuery.refreshIdentityMapResult(); } return cascadeQuery; }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ protected void mergeClientIntoServerValueHolder(RemoteValueHolder serverValueHolder, MergeManager mergeManager) { serverValueHolder.setMapping(this.mapping); serverValueHolder.setSession(mergeManager.getSession()); if (this.mapping.isForeignReferenceMapping()) { ObjectLevelReadQuery query = buildCascadeQuery(mergeManager); serverValueHolder.setQuery(query); } }
refreshCascade = query.getCascadePolicy(); return this.indirectionPolicy.cloneAttribute(attributeValue, cached, parentCacheKey, object, refreshCascade, executionSession, false); return getAttributeValueFromObject(row.getSopObject()); Object attributeValue = this.indirectionPolicy.valueFromMethod(object, row, query.getSession()); Object oldAttribute = null; if (executionSession.isUnitOfWork() && query.shouldRefreshIdentityMapResult()){ if (this.indirectionPolicy.objectIsInstantiatedOrChanged(oldAttribute)){ this.indirectionPolicy.instantiateObject(object, attributeValue);
refreshCascade = sourceQuery.getCascadePolicy(); attributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, parentCacheKey.getObject(), parentCacheKey, targetObject, refreshCascade, executionSession, false); Object oldAttribute = this.getAttributeValueFromObject(targetObject); if (wasAttributeValueFullyBuilt && this.indirectionPolicy.objectIsInstantiatedOrChanged(oldAttribute)){ this.indirectionPolicy.instantiateObject(targetObject, attributeValue); this.indirectionPolicy.setSourceObject(parentCacheKey.getObject(), attributeValue);