/** * INTERNAL: * Return a backup clone of the attribute. */ public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) { // delay instantiation until absolutely necessary if ((!(attributeValue instanceof IndirectContainer)) || objectIsInstantiated(attributeValue)) { return super.backupCloneAttribute(attributeValue, clone, backup, unitOfWork); } else { return buildBackupClone((IndirectContainer)attributeValue); } }
/** * INTERNAL: This method can be used when an Indirection Object is required * to be built from a provided ValueHolderInterface object. This may be used * for custom value holder types. Certain policies like the * TransparentIndirectionPolicy may wrap the valueholder in another object. */ public Object buildIndirectObject(ValueHolderInterface valueHolder){ return buildIndirectContainer(valueHolder); } /**
/** * INTERNAL: * Verify that the container policy is compatible with the * indirection policy. If it is incorrect, add an exception to the * integrity checker. */ public void validateContainerPolicy(IntegrityChecker checker) throws DescriptorException { super.validateContainerPolicy(checker); if (!this.containerPolicyIsValid()) { checker.handleError(DescriptorException.invalidContainerPolicyWithTransparentIndirection(this.getMapping(), this.getContainerPolicy())); } // Bug 2618982 if (getContainerPolicy().isMapPolicy() && ((((ForeignReferenceMapping)getMapping()).getRelationshipPartnerAttributeName() != null) || (getMapping().getRelationshipPartner() != null))) { checker.handleError(DescriptorException.unsupportedTypeForBidirectionalRelationshipMaintenance(this.getMapping(), this.getContainerPolicy())); } }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { return this.buildIndirectContainer(new BatchValueHolder(batchQuery, row, getForeignReferenceMapping(), originalQuery, parentCacheKey)); }
/** * INTERNAL: * Return the original indirection object for a unit of work indirection object. */ @Override public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session) { IndirectContainer container = (IndirectContainer)unitOfWorkIndirectionObject; if (container.getValueHolder() instanceof UnitOfWorkValueHolder) { return buildIndirectContainer((ValueHolderInterface) getOriginalValueHolder(unitOfWorkIndirectionObject, session)); } else { return container; } }
/** * INTERNAL: * Verify that attributeType is correct for the * indirection policy. If it is incorrect, add an exception to the * integrity checker. * In this case, the attribute type MUST be * compatible with the one specified by the ContainerPolicy. */ public void validateDeclaredAttributeType(Class attributeType, IntegrityChecker checker) throws DescriptorException { super.validateDeclaredAttributeType(attributeType, checker); if (!this.typeIsValid(attributeType)) { checker.handleError(DescriptorException.attributeAndMappingWithTransparentIndirectionMismatch(this.getMapping(), attributeType, this.validTypeName())); } }
/** * PUBLIC: * Configure the mapping to use an instance of the specified container class * to hold the target objects. * <p>The container class must implement (directly or indirectly) the Map interface. * <p>Note: Do not use both useMapClass(Class concreteClass), useTransparentMap(). The last use of one of the two methods will override the previous one. */ public void useTransparentMap() { setIndirectionPolicy(new TransparentIndirectionPolicy()); useMapClass(ClassConstants.IndirectMap_Class); }
/** * INTERNAL: * Return the null value of the appropriate attribute. That is, the * field from the database is NULL, return what should be * placed in the object's attribute as a result. * OneToOneMappings should not be using transparent direction. */ public Object nullValueFromRow() { throw DescriptorException.invalidUseOfTransparentIndirection(this.getMapping()); }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ public void mergeRemoteValueHolder(Object clientSideDomainObject, Object serverSideDomainObject, MergeManager mergeManager) { // This will always be a transparent with a remote. IndirectContainer serverContainer = (IndirectContainer)getMapping().getAttributeValueFromObject(serverSideDomainObject); RemoteValueHolder serverValueHolder = (RemoteValueHolder)serverContainer.getValueHolder(); mergeClientIntoServerValueHolder(serverValueHolder, mergeManager); getMapping().setAttributeValueInObject(clientSideDomainObject, serverContainer); }
/** * Construct and return an instance of the specified * indirect container class. */ protected IndirectContainer buildIndirectContainer() { //3732 if (defaultContainerSize != null) { return (IndirectContainer)getContainerPolicy().containerInstance(getDefaultContainerSize()); } else { return (IndirectContainer)getContainerPolicy().containerInstance(); } }
/** * INTERNAL: * Trigger the instantiation of the value. */ public void instantiateObject(Object object, Object attribute) { getContainerPolicy().sizeFor(attribute); }
/** * INTERNAL: * Return the type that is appropriate for the indirection policy. */ protected String validTypeName() { return Helper.getShortClassName(this.getContainerClass()); }
/** * INTERNAL: * Return the container policy for the mapping. */ protected ContainerPolicy getContainerPolicy() { if (this.containerPolicy == null) { this.containerPolicy = getCollectionMapping().getContainerPolicy(); } return this.containerPolicy; }
/** * INTERNAL: * Verify that setter parameterType is correct for the * indirection policy. If it is incorrect, add an exception * to the integrity checker. * In this case, the attribute type MUST be * compatible with the one specified by the ContainerPolicy. */ public void validateSetMethodParameterType(Class parameterType, IntegrityChecker checker) throws DescriptorException { super.validateSetMethodParameterType(parameterType, checker); if (!this.typeIsValid(parameterType)) { checker.handleError(DescriptorException.parameterAndMappingWithTransparentIndirectionMismatch(this.getMapping(), parameterType, this.validTypeName())); } }
/** * PUBLIC: * Configure the mapping to use an instance of the specified container class * to hold the target objects. * <p>The container class must implement (directly or indirectly) the Map interface. * <p>Note: Do not use both useMapClass(Class concreteClass), useTransparentMap(). The last use of one of the two methods will override the previous one. */ public void useTransparentMap() { setIndirectionPolicy(new TransparentIndirectionPolicy()); useMapClass(ClassConstants.IndirectMap_Class); }
/** * INTERNAL: * Return the primary key for the reference object (i.e. the object * object referenced by domainObject and specified by mapping). * This key will be used by a RemoteValueHolder. * OneToOneMappings should not be using transparent direction. */ @Override public Object extractPrimaryKeyForReferenceObject(Object referenceObject, AbstractSession session) { throw DescriptorException.invalidUseOfTransparentIndirection(this.getMapping()); }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ public void mergeRemoteValueHolder(Object clientSideDomainObject, Object serverSideDomainObject, MergeManager mergeManager) { // This will always be a transparent with a remote. IndirectContainer serverContainer = (IndirectContainer)getMapping().getAttributeValueFromObject(serverSideDomainObject); RemoteValueHolder serverValueHolder = (RemoteValueHolder)serverContainer.getValueHolder(); mergeClientIntoServerValueHolder(serverValueHolder, mergeManager); getMapping().setAttributeValueInObject(clientSideDomainObject, serverContainer); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery) { return this.buildIndirectContainer(new BatchValueHolder(batchQuery, row, getForeignReferenceMapping(), originalQuery)); }
/** * Construct and return an instance of the specified * indirect container class. */ protected IndirectContainer buildIndirectContainer() { IndirectContainer container = null; //3732 if (defaultContainerSize != null) { container = (IndirectContainer)getContainerPolicy().containerInstance(getDefaultContainerSize()); } else { container = (IndirectContainer)getContainerPolicy().containerInstance(); } if (container instanceof IndirectCollection){ if (this.useLazyInstantiation != null){ ((IndirectCollection)container).setUseLazyInstantiation(this.useLazyInstantiation.booleanValue()); } } return container; }
/** * INTERNAL: * Return the container class for the mapping. */ protected Class getContainerClass() { return this.getContainerPolicy().getContainerClass(); }