Class AbstractTransformationMapping

    • Field Detail

      • attributeTransformerClassName

        protected String attributeTransformerClassName
        Name of the class which implements AttributeTransformer to be used to retrieve the attribute value
      • attributeTransformer

        protected AttributeTransformer attributeTransformer
        attributeTransformerClassName is converter to an instance of AttributeTransformer
      • fieldTransformations

        protected List<FieldTransformation> fieldTransformations
        Stores field name and the class name of a FieldTransformer in a vector to preserve order
      • fieldToTransformers

        protected List<Object[]> fieldToTransformers
        The TransformerClassNames are converted into instances of FieldTransformer
      • isMutable

        protected boolean isMutable
        PERF: Indicates if this mapping's attribute is a simple value which cannot be modified only replaced.
      • indirectionPolicy

        protected IndirectionPolicy indirectionPolicy
        Implements indirection behaviour
    • Constructor Detail

      • AbstractTransformationMapping

        public AbstractTransformationMapping()
        PUBLIC: Default constructor.
    • Method Detail

      • addFieldTransformation

        public void addFieldTransformation​(DatabaseField field,
                                           String methodName)
        PUBLIC: Add the field and the name of the method that returns the value to be placed in said field when the object is written to the database. The method may take zero arguments, or it may take a single argument of type org.eclipse.persistence.sessions.Session.
      • addFieldTransformation

        public void addFieldTransformation​(String fieldName,
                                           String methodName)
        PUBLIC: Add the name of field and the name of the method that returns the value to be placed in said field when the object is written to the database. The method may take zero arguments, or it may take a single argument of type org.eclipse.persistence.sessions.Session.
      • addFieldTransformerClassName

        public void addFieldTransformerClassName​(String fieldName,
                                                 String className)
        INTERNAL: Add the name of a field and the name of a class which implements the FieldTransformer interface. When the object is written, the transform method will be called on the FieldTransformer to acquire the value to put in the field.
      • addFieldTransformerClassName

        public void addFieldTransformerClassName​(DatabaseField field,
                                                 String className)
        INTERNAL: Add the name of a field and the name of a class which implements the FieldTransformer interface. When the object is written, the transform method will be called on the FieldTransformer to acquire the value to put in the field.
      • addFieldTransformer

        public void addFieldTransformer​(String fieldName,
                                        FieldTransformer transformer)
        PUBLIC: Add the name of field and the transformer that returns the value to be placed in the field when the object is written to the database.
      • addFieldTransformer

        public void addFieldTransformer​(DatabaseField field,
                                        FieldTransformer transformer)
        PUBLIC: Add the field and the transformer that returns the value to be placed in the field when the object is written to the database.
      • areObjectsToBeProcessedInstantiated

        protected boolean areObjectsToBeProcessedInstantiated​(Object object)
        INTERNAL: The referenced object is checked if it is instantiated or not
      • buildPhantomRowFrom

        protected AbstractRecord buildPhantomRowFrom​(Object domainObject,
                                                     AbstractSession session)
        INTERNAL Build a phantom row that contains only the fields for the mapping, populated with the values generated by invoking the field methods on the specified object.
      • buildShallowOriginalFromRow

        public void buildShallowOriginalFromRow​(AbstractRecord record,
                                                Object original,
                                                JoinedAttributeManager joinManager,
                                                ObjectBuildingQuery query,
                                                AbstractSession executionSession)
        INTERNAL: Builds a shallow original object. Only direct attributes and primary keys are populated. In this way the minimum original required for instantiating a working copy clone can be built without placing it in the shared cache (no concern over cycles).
        Overrides:
        buildShallowOriginalFromRow in class DatabaseMapping
        Parameters:
        original - later the input to buildCloneFromRow
      • buildBackupCloneForPartObject

        public Object buildBackupCloneForPartObject​(Object attributeValue,
                                                    Object clone,
                                                    Object backup,
                                                    UnitOfWorkImpl unitOfWork)
        INTERNAL: Used during building the backup shallow copy to copy the vector without re-registering the target objects. For 1-1 or ref the reference is from the clone so it is already registered.
        Overrides:
        buildBackupCloneForPartObject in class DatabaseMapping
      • buildCopy

        public void buildCopy​(Object copy,
                              Object original,
                              CopyGroup group)
        INTERNAL: Copy of the attribute of the object. This is NOT used for unit of work but for templatizing an object.
        Overrides:
        buildCopy in class DatabaseMapping
      • clone

        public Object clone()
        INTERNAL: The mapping clones itself to create deep copy.
        Overrides:
        clone in class DatabaseMapping
      • convertClassNamesToClasses

        public void convertClassNamesToClasses​(ClassLoader classLoader)
        INTERNAL: Convert all the class-name-based settings in this mapping to actual class-based settings
        Overrides:
        convertClassNamesToClasses in class DatabaseMapping
        Parameters:
        classLoader -
      • dontUseIndirection

        public void dontUseIndirection()
        PUBLIC: Indirection means that 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.
      • getAttributeTransformer

        public AttributeTransformer getAttributeTransformer()
        INTERNAL: The attributeTransformer stores an instance of the class which implements AttributeTransformer.
      • getAttributeMethodName

        public String getAttributeMethodName()
        PUBLIC: Return the attribute transformation method name.
      • getAttributeTransformerClass

        public Class getAttributeTransformerClass()
        INTERNAL: Return the attribute transformer's class. This is used to map to XML.
      • setAttributeTransformerClass

        public void setAttributeTransformerClass​(Class attributeTransformerClass)
        INTERNAL: Set the attribute transformer's class. This is used to map from XML.
      • getAttributeTransformerClassName

        public String getAttributeTransformerClassName()
        INTERNAL: Return the attribute transformer class name
      • getFieldTransformations

        public List<FieldTransformation> getFieldTransformations()
        INTERNAL: Returns a Vector which stores fieldnames and the respective method/transformer names.
      • getFieldToTransformers

        public List<Object[]> getFieldToTransformers()
        INTERNAL:
        Returns:
        a vector which stores fields and their respective transformers.
      • getIndirectionPolicy

        public IndirectionPolicy getIndirectionPolicy()
        INTERNAL: Return the mapping's indirection policy.
      • getRealAttributeValueFromAttribute

        public Object getRealAttributeValueFromAttribute​(Object attributeValue,
                                                         Object object,
                                                         AbstractSession session)
        INTERNAL: Returns the real attribute value from the reference object's attribute value. If the attribute is using indirection the value of the value-holder is returned. If the value holder is not instantiated then it is instantiated.
        Overrides:
        getRealAttributeValueFromAttribute in class DatabaseMapping
      • initializeAttributeTransformer

        protected void initializeAttributeTransformer​(AbstractSession databaseSession)
                                               throws DescriptorException
        INTERNAL: Convert the attribute transformer class name into an AttributeTransformer If the old-style method name in set, then use a MethodBasedAttributeTRansformer
        Throws:
        DescriptorException
      • getFieldNameToMethodNames

        public Hashtable getFieldNameToMethodNames()
        INTERNAL: Required for reverse compatibility and test cases:
        Returns:
        a hash table containing the fieldName and their respective method names
      • isMutable

        public boolean isMutable()
        PUBLIC: Return true if the attribute for this mapping is not a simple atomic value that cannot be modified, only replaced. This is true by default for non-primitives, but can be set to false to avoid cloning and change comparison in the unit of work.
      • isReadOnly

        public boolean isReadOnly()
        INTERNAL: Return true if read-only is explicitly set to true; otherwise return whether the transformation has no fields (no fields = read-only)
        Overrides:
        isReadOnly in class DatabaseMapping
      • isWriteOnly

        public boolean isWriteOnly()
        INTERNAL: Return if the transformation has no attribute, is write only.
        Overrides:
        isWriteOnly in class DatabaseMapping
      • iterate

        public void iterate​(DescriptorIterator iterator)
        INTERNAL: Perform the iteration opperation on the iterators current objects attributes. Only require if primitives are desired.
        Specified by:
        iterate in class DatabaseMapping
      • getFieldNameToMethodNameAssociations

        public Vector getFieldNameToMethodNameAssociations()
        INTERNAL: Needed for backwards compatibility
      • setFieldNameToMethodNameAssociations

        public void setFieldNameToMethodNameAssociations​(Vector associations)
        INTERNAL: needed for backwards compatibility
      • remoteInitialization

        public void remoteInitialization​(DistributedSession session)
        INTERNAL: Once descriptors are serialized to the remote session. All its mappings and reference descriptors are traversed. Usually mappings are initialized and serialized reference descriptors are replaced with local descriptors if they already exist on the remote session.
        Overrides:
        remoteInitialization in class DatabaseMapping
      • setAttributeTransformer

        public void setAttributeTransformer​(AttributeTransformer transformer)
        PUBLIC: Set the AttributeTransformer, this transformer will be used to extract the value for the object's attribute from the database row.
      • setAttributeTransformerClassName

        public void setAttributeTransformerClassName​(String className)
        INTERNAL: Set the Attribute Transformer Class Name
        Parameters:
        className -
      • setAttributeTransformation

        public void setAttributeTransformation​(String methodName)
        PUBLIC: To set the attribute method name. The method is invoked internally by TopLink to retrieve the value to store in the domain object. The method receives Record as its parameter and optionally Session, and should extract the value from the record to set into the object, but should not set the value on the object, only return it.
      • setIsMutable

        public void setIsMutable​(boolean mutable)
        PUBLIC: Set if the value of the attribute is atomic or a complex mutable object and can be modified without replacing the entire object. This defaults to true for non-primitives, but can be set to false to optimize object cloning and change comparison.
      • setFieldTransformations

        public void setFieldTransformations​(List<FieldTransformation> fieldTransformations)
        INTERNAL: Set the field to method name associations.
      • setFieldToTransformers

        protected void setFieldToTransformers​(List<Object[]> fieldToTransformers)
      • setIndirectionPolicy

        public void setIndirectionPolicy​(IndirectionPolicy indirectionPolicy)
        ADVANCED: Set the indirection policy.
      • setUsesIndirection

        public void setUsesIndirection​(boolean usesIndirection)
        INTERNAL: Will be used by Gromit. For details see usesIndirection().
        See Also:
        useBasicIndirection(), dontUseIndirection()
      • useBasicIndirection

        public void useBasicIndirection()
        PUBLIC: Indirection means that 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.
      • useContainerIndirection

        public void useContainerIndirection​(Class containerClass)
        PUBLIC: Indirection means that a IndirectContainer (wrapping a ValueHolder) will be put in-between the attribute and the real object. This allows for the reading of the target from the database to be delayed until accessed. This defaults to true and is strongly suggested as it give a huge performance gain.
      • useIndirection

        public void useIndirection()
        PUBLIC: Indirection means that 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 Also:
        useBasicIndirection()
      • usesIndirection

        public boolean usesIndirection()
        PUBLIC: Indirection means that 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 Also:
        IndirectionPolicy