@Override public Object getAttributeValueFromObject(Object object) { IndirectionPolicy policy = ((AbstractTransformationMapping)object).getIndirectionPolicy(); if (policy instanceof NoIndirectionPolicy) { return null; } return policy; }
public Object getAttributeValueFromObject(Object object) { IndirectionPolicy policy = ((AbstractTransformationMapping)object).getIndirectionPolicy(); if (policy instanceof NoIndirectionPolicy) { return null; } return policy; }
public Object getAttributeValueFromObject(Object object) { IndirectionPolicy policy = ((AbstractTransformationMapping)object).getIndirectionPolicy(); if (policy instanceof NoIndirectionPolicy) { return null; } return policy; }
/** * 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. */ public void fixObjectReferences(Object object, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, RemoteSession session) { getIndirectionPolicy().fixObjectReferences(object, objectDescriptors, processedObjects, query, session); }
/** * PUBLIC: * Indirection meansthat a ValueHolder will be put in-between the attribute and the real object. * This defaults to false and only required for transformations that perform database access. * @see org.eclipse.persistence.mappings.IndirectionPolicy */ public boolean usesIndirection() { return getIndirectionPolicy().usesIndirection(); }
/** * INTERNAL: * Extract and return the appropriate value from the * specified remote value holder. */ public Object getValueFromRemoteValueHolder(RemoteValueHolder remoteValueHolder) { return getIndirectionPolicy().getValueFromRemoteValueHolder(remoteValueHolder); }
/** * INTERNAL: * The referenced object is checked if it is instantiated or not */ protected boolean areObjectsToBeProcessedInstantiated(Object object) { return getIndirectionPolicy().objectIsInstantiated(getAttributeValueFromObject(object)); }
/** * INTERNAL: * Trigger the instantiation of the attribute if lazy. */ public void instantiateAttribute(Object object, AbstractSession session) { getIndirectionPolicy().instantiateObject(object, getAttributeValueFromObject(object)); }
/** * INTERNAL: * Set the value of the attribute mapped by this mapping, * placing it inside a value holder if necessary. * If the value holder is not instantiated then it is instantiated. * Check for write-only, one-way transformations. */ public void setRealAttributeValueInObject(Object object, Object value) throws DescriptorException { if (this.isWriteOnly()) { return; } this.getIndirectionPolicy().setRealAttributeValueInObject(object, value); }
/** * INTERNAL: * Check for write-only, one-way transformation. */ public Object getAttributeValueFromObject(Object object) throws DescriptorException { if (isWriteOnly()) { return null; } Object attributeValue = super.getAttributeValueFromObject(object); return getIndirectionPolicy().validateAttributeOfInstantiatedObject(attributeValue); }
/** * INTERNAL: * Perform the iteration opperation on the iterators current objects attributes. * Only require if primitives are desired. */ public void iterate(DescriptorIterator iterator) { Object attributeValue = getAttributeValueFromObject(iterator.getVisitedParent()); getIndirectionPolicy().iterateOnAttributeValue(iterator, attributeValue); }
/** * INTERNAL: * The mapping is initialized with the given session. */ public void initialize(AbstractSession session) throws DescriptorException { super.initialize(session); initializeAttributeTransformer(session); initializeFieldToTransformers(session); setFields(collectFields()); getIndirectionPolicy().initialize(); }
if ((cloneAttribute != null) && (!getIndirectionPolicy().objectIsInstantiated(cloneAttribute))) { return null; backUpAttribute = getAttributeValueFromObject(backUp); boolean backUpIsInstantiated = ((backUpAttribute == null) || (getIndirectionPolicy().objectIsInstantiated(backUpAttribute)));
/** * INTERNAL: * Extract value from the row and set the attribute to the value in the object. */ public Object readFromRowIntoObject(AbstractRecord row, JoinedAttributeManager joinManager, Object object, ObjectBuildingQuery query, AbstractSession executionSession) throws DatabaseException { if (isWriteOnly()) { return null; } Object attributeValue = getIndirectionPolicy().valueFromMethod(object, row, query.getSession()); try { getAttributeAccessor().setAttributeValueInObject(object, attributeValue); } catch (DescriptorException exception) { exception.setMapping(this); throw exception; } return attributeValue; }
/** * INTERNAL: * Clone the attribute from the original and assign it to the clone. */ public void buildClone(Object original, Object clone, UnitOfWorkImpl unitOfWork) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(original); Object clonedAttributeValue; // If the mapping is read-only, a direct pass through of the value will be performed. // This is done because the method invocation is not possible as the row will be // empty and we have no way to clone the value. // Since the value cannot change anyway we just pass it through. if (isReadOnly() || !isMutable()) { clonedAttributeValue = attributeValue; } else { clonedAttributeValue = getIndirectionPolicy().cloneAttribute(attributeValue, original, clone, unitOfWork, false);// building clone from an original not a row. } setAttributeValueInObject(clone, clonedAttributeValue); }
/** * INTERNAL: * 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 record, JoinedAttributeManager joinManager, Object clone, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } // This will set the value in the clone automatically. Object attributeValue = readFromRowIntoObject(record, joinManager, clone, sourceQuery, executionSession); Object clonedAttributeValue; // If the mapping is read-only, a direct pass through of the value will be performed. // This is done because the method invocation is not possible as the row will be // empty and we have no way to clone the value. // Since the value cannot change anyway we just pass it through. if (isReadOnly() || !isMutable()) { clonedAttributeValue = attributeValue; } else { clonedAttributeValue = getIndirectionPolicy().cloneAttribute(attributeValue, null,// no original clone, unitOfWork, true);// build clone directly from row. } setAttributeValueInObject(clone, clonedAttributeValue); }
/** * INTERNAL: * Validate mapping declaration */ public void validateBeforeInitialization(AbstractSession session) throws DescriptorException { super.validateBeforeInitialization(session); if (isWriteOnly()) { return; } if ((getAttributeTransformer() == null) && (getAttributeTransformerClassName() == null)) { session.getIntegrityChecker().handleError(DescriptorException.noAttributeTransformationMethod(this)); } if (getAttributeAccessor() instanceof InstanceVariableAttributeAccessor) { Class attributeType = ((InstanceVariableAttributeAccessor)getAttributeAccessor()).getAttributeType(); getIndirectionPolicy().validateDeclaredAttributeType(attributeType, session.getIntegrityChecker()); } else if (getAttributeAccessor().isMethodAttributeAccessor()) { Class returnType = ((MethodAttributeAccessor)getAttributeAccessor()).getGetMethodReturnType(); getIndirectionPolicy().validateGetMethodReturnType(returnType, session.getIntegrityChecker()); Class parameterType = ((MethodAttributeAccessor)getAttributeAccessor()).getSetMethodParameterType(); getIndirectionPolicy().validateSetMethodParameterType(parameterType, session.getIntegrityChecker()); } }
/** * INTERNAL: * Clone the attribute from the clone and assign it to the backup. */ public void buildBackupClone(Object clone, Object backup, UnitOfWorkImpl unitOfWork) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(clone); if (!isMutable()) { setAttributeValueInObject(backup, attributeValue); return; } Object clonedAttributeValue; // If the mapping is read-only, a direct pass through of the value will be performed. // This is done because the method invocation is not possible as the row will be // empty and we have no way to clone the value. // Since the value cannot change anyway we just pass it through. if (isReadOnly()) { clonedAttributeValue = attributeValue; } else { clonedAttributeValue = getIndirectionPolicy().backupCloneAttribute(attributeValue, clone, backup, unitOfWork); } setAttributeValueInObject(backup, clonedAttributeValue); }
AbstractTransformationMapping transMapping = (AbstractTransformationMapping)baseMapping; if (transMapping.usesIndirection()) { allAttributesNull = transMapping.getIndirectionPolicy().objectIsInstantiated(baseValue);
getIndirectionPolicy().mergeRemoteValueHolder(target, source, mergeManager); return; setAttributeValueInObject(target, getIndirectionPolicy().getOriginalIndirectionObject(getAttributeValueFromObject(source), mergeManager.getSession())); return;