Class AbstractDirectMapping

    • Field Detail

      • attributeClassification

        protected transient java.lang.Class attributeClassification
        To specify the conversion type
      • attributeClassificationName

        protected java.lang.String attributeClassificationName
      • attributeObjectClassification

        protected transient java.lang.Class attributeObjectClassification
        PERF: Also store object class of attribute in case of primitive.
      • nullValue

        protected transient java.lang.Object nullValue
        Support specification of the value to use for null.
      • fieldClassificationClassName

        protected java.lang.String fieldClassificationClassName
      • bypassDefaultNullValueCheck

        protected boolean bypassDefaultNullValueCheck
        PERF: Avoid default null value conversion check if not default null value set in conversion manager.
      • isMutable

        protected java.lang.Boolean isMutable
        PERF: Indicates if this mapping's attribute is a simple atomic value and cannot be modified, only replaced. This is a tri-state to allow user to set to true or false, as default is false but some data-types such as Calendar or byte[] or converter types may be desired to be used as mutable.
    • Constructor Detail

      • AbstractDirectMapping

        public AbstractDirectMapping()
        Default constructor.
    • Method Detail

      • addAdditionalFieldsToQuery

        public void addAdditionalFieldsToQuery​(ReadQuery selectionQuery,
                                               Expression baseExpression)
        INTERNAL: Used when initializing queries for mappings that use a Map. Called when the selection query is being initialized to add the fields for the map key to the query.
        Specified by:
        addAdditionalFieldsToQuery in interface MapKeyMapping
      • addFieldsForMapKey

        public void addFieldsForMapKey​(AbstractRecord joinRow)
        INTERNAL: Used when initializing queries for mappings that use a Map Called when the insert query is being initialized to ensure the fields for the map key are in the insert query.
        Specified by:
        addFieldsForMapKey in interface MapKeyMapping
      • addKeyToDeletedObjectsList

        public void addKeyToDeletedObjectsList​(java.lang.Object object,
                                               java.util.Map deletedObjects)
        INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy. Add the target of this mapping to the deleted objects list if necessary This method is used for removal of private owned relationships DirectMappings are dealt with in their parent delete, so this is a no-op.
        Specified by:
        addKeyToDeletedObjectsList in interface MapKeyMapping
      • isMutable

        public boolean isMutable()
        PUBLIC: Return true if the attribute for this mapping is a simple atomic value that cannot be modified, only replaced. This is false by default unless a mutable converter is used such as the SerializedObjectConverter. This can be set to false in this case, or if a Calendar or byte[] is desired to be used as a mutable value it can be set to true.
      • setIsMutable

        public void setIsMutable​(boolean isMutable)
        PUBLIC: Return true if the attribute for this mapping is a simple atomic value that cannot be modified, only replaced. This is false by default unless a mutable converter is used such as the SerializedObjectConverter. This can be set to false in this case, or if a Calendar or byte[] is desired to be used as a mutable value it can be set to true.
      • buildBackupClone

        public void buildBackupClone​(java.lang.Object clone,
                                     java.lang.Object backup,
                                     UnitOfWorkImpl unitOfWork)
        INTERNAL: Clone the attribute from the clone and assign it to the backup.
        Specified by:
        buildBackupClone in class DatabaseMapping
      • buildClone

        public void buildClone​(java.lang.Object original,
                               CacheKey cacheKey,
                               java.lang.Object clone,
                               java.lang.Integer refreshCascade,
                               AbstractSession cloningSession)
        INTERNAL: Clone the attribute from the original and assign it to the clone.
        Specified by:
        buildClone in class DatabaseMapping
      • buildCloneValue

        public void buildCloneValue​(java.lang.Object original,
                                    java.lang.Object clone,
                                    AbstractSession session)
        INTERNAL: Clone the attribute from the original and assign it to the clone. If mutability is configured to be true, clone the attribute if it is an instance of byte[], java.util.Calendar or java.util.Date (or their subclasses).
      • buildCloneValue

        protected java.lang.Object buildCloneValue​(java.lang.Object attributeValue,
                                                   AbstractSession session)
        INTERNAL: Clone the actual value represented by this mapping. Do set the cloned value into the object.
      • buildCopy

        public void buildCopy​(java.lang.Object copy,
                              java.lang.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
      • buildElementClone

        public java.lang.Object buildElementClone​(java.lang.Object attributeValue,
                                                  java.lang.Object parent,
                                                  CacheKey cacheKey,
                                                  java.lang.Integer refreshCascade,
                                                  AbstractSession cloningSession,
                                                  boolean isExisting,
                                                  boolean isFromSharedCache)
        Build a clone of the given element in a unitOfWork.
        Specified by:
        buildElementClone in interface MapKeyMapping
        Returns:
      • buildExpression

        public Expression buildExpression​(java.lang.Object queryObject,
                                          QueryByExamplePolicy policy,
                                          Expression expressionBuilder,
                                          java.util.Map processedObjects,
                                          AbstractSession session)
        INTERNAL: In case Query By Example is used, this method builds and returns an expression that corresponds to a single attribute and it's value for a directToField mapping.
        Overrides:
        buildExpression in class DatabaseMapping
      • cascadeDiscoverAndPersistUnregisteredNewObjects

        public void cascadeDiscoverAndPersistUnregisteredNewObjects​(java.lang.Object object,
                                                                    java.util.Map newObjects,
                                                                    java.util.Map unregisteredExistingObjects,
                                                                    java.util.Map visitedObjects,
                                                                    UnitOfWorkImpl uow,
                                                                    boolean getAttributeValueFromObject,
                                                                    java.util.Set cascadeErrors)
        INTERNAL: Cascade discover and persist new objects during commit to the map key.
        Specified by:
        cascadeDiscoverAndPersistUnregisteredNewObjects in interface MapKeyMapping
      • cascadePerformRemoveIfRequired

        public void cascadePerformRemoveIfRequired​(java.lang.Object object,
                                                   UnitOfWorkImpl uow,
                                                   java.util.Map visitedObjects,
                                                   boolean getAttributeValueFromObject)
        INTERNAL: Cascade perform delete through mappings that require the cascade.
        Specified by:
        cascadePerformRemoveIfRequired in interface MapKeyMapping
      • cascadeRegisterNewIfRequired

        public void cascadeRegisterNewIfRequired​(java.lang.Object object,
                                                 UnitOfWorkImpl uow,
                                                 java.util.Map visitedObjects,
                                                 boolean getAttributeValueFromObject)
        INTERNAL: Cascade registerNew for Create through mappings that require the cascade.
        Specified by:
        cascadeRegisterNewIfRequired in interface MapKeyMapping
      • deleteMapKey

        public void deleteMapKey​(java.lang.Object objectDeleted,
                                 AbstractSession session)
        INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy, Delete the passed object if necessary. This method is used for removal of private owned relationships DirectMappings are dealt with in their parent delete, so this is a no-op.
        Specified by:
        deleteMapKey in interface MapKeyMapping
      • compareObjects

        public boolean compareObjects​(java.lang.Object firstObject,
                                      java.lang.Object secondObject,
                                      AbstractSession session)
        INTERNAL: Compare the attributes belonging to this mapping for the objects.
        Specified by:
        compareObjects in class DatabaseMapping
      • compareObjectValues

        protected boolean compareObjectValues​(java.lang.Object firstValue,
                                              java.lang.Object secondValue,
                                              AbstractSession session)
        INTERNAL: Compare the attribute values.
      • convertClassNamesToClasses

        public void convertClassNamesToClasses​(java.lang.ClassLoader classLoader)
        INTERNAL: Convert all the class-name-based settings in this mapping to actual class-based settings This method is implemented by subclasses as necessary.
        Overrides:
        convertClassNamesToClasses in class AbstractColumnMapping
      • createSerializableMapKeyInfo

        public java.lang.Object createSerializableMapKeyInfo​(java.lang.Object key,
                                                             AbstractSession session)
        INTERNAL: Creates the Array of simple types used to recreate this map.
        Specified by:
        createSerializableMapKeyInfo in interface MapKeyMapping
      • createMapComponentsFromSerializableKeyInfo

        public java.util.List<java.lang.Object> createMapComponentsFromSerializableKeyInfo​(java.lang.Object[] keyInfo,
                                                                                           AbstractSession session)
        INTERNAL: Create an instance of the Key object from the key information extracted from the map. This may return the value directly in case of a simple key or will be used as the FK to load a related entity.
        Specified by:
        createMapComponentsFromSerializableKeyInfo in interface MapKeyMapping
      • createStubbedMapComponentFromSerializableKeyInfo

        public java.lang.Object createStubbedMapComponentFromSerializableKeyInfo​(java.lang.Object keyInfo,
                                                                                 AbstractSession session)
        INTERNAL: Create an instance of the Key object from the key information extracted from the map. This key object may be a shallow stub of the actual object if the key is an Entity type.
        Specified by:
        createStubbedMapComponentFromSerializableKeyInfo in interface MapKeyMapping
      • extractIdentityFieldsForQuery

        public java.util.Map extractIdentityFieldsForQuery​(java.lang.Object object,
                                                           AbstractSession session)
        INTERNAL: Extract the fields for the Map key from the object to use in a query.
        Specified by:
        extractIdentityFieldsForQuery in interface MapKeyMapping
        Returns:
      • getAdditionalTablesForJoinQuery

        public java.util.List<DatabaseTable> getAdditionalTablesForJoinQuery()
        INTERNAL: Return any tables that will be required when this mapping is used as part of a join query.
        Specified by:
        getAdditionalTablesForJoinQuery in interface MapKeyMapping
        Returns:
      • getAttributeClassification

        public java.lang.Class getAttributeClassification()
        PUBLIC: Some databases do not properly support all of the base data types. For these databases, the base data type must be explicitly specified in the mapping to tell EclipseLink to force the instance variable value to that data type.
        Overrides:
        getAttributeClassification in class DatabaseMapping
      • getAttributeClassificationName

        public java.lang.String getAttributeClassificationName()
        INTERNAL: Return the class name of the attribute type. This is only used by the MW.
      • getObjectValue

        public java.lang.Object getObjectValue​(java.lang.Object fieldValue,
                                               Session session)
        INTERNAL: Allows for subclasses to convert the attribute value.
        Specified by:
        getObjectValue in class AbstractColumnMapping
      • getObjectValueWithoutClassCheck

        public java.lang.Object getObjectValueWithoutClassCheck​(java.lang.Object fieldValue,
                                                                Session session)
        INTERNAL: Same as getObjectValue method, but without checking fieldValue's class. Used in case the fieldValue class is already known to be the same as attributeClassification.
      • getFieldClassification

        public java.lang.Class getFieldClassification​(DatabaseField fieldToClassify)
        INTERNAL: Return the classification for the field contained in the mapping. This is used to convert the row value to a consistent Java value.
        Overrides:
        getFieldClassification in class DatabaseMapping
      • getFieldClassification

        public java.lang.Class getFieldClassification()
        ADVANCED: Return the class type of the field value. This can be used if field value differs from the object value, has specific typing requirements such as usage of java.sql.Blob or NChar.
      • setFieldClassification

        public void setFieldClassification​(java.lang.Class fieldType)
        ADVANCED: Set the class type of the field value. This can be used if field value differs from the object value, has specific typing requirements such as usage of java.sql.Blob or NChar. This must be called after the field name has been set.
      • setFieldClassificationClassName

        public void setFieldClassificationClassName​(java.lang.String className)
        INTERNAL: Set the name of the class that will be used for setFieldClassification and deploy time Used internally by JPA deployment.
        Parameters:
        className -
        See Also:
        setFieldClassification(Class fieldType)
      • setFieldType

        public void setFieldType​(int jdbcType)
        ADVANCED: Set the JDBC type of the field value. This can be used if field type does not correspond directly to a Java class type, such as MONEY. This is used for binding.
      • getFieldName

        public java.lang.String getFieldName()
        PUBLIC: Name of the field this mapping represents.
      • getFieldValue

        public java.lang.Object getFieldValue​(java.lang.Object attributeValue,
                                              AbstractSession session)
        INTERNAL: Convert the attribute value to a field value. Process any converter if defined, and check for null values.
        Specified by:
        getFieldValue in class AbstractColumnMapping
      • getIdentityFieldsForMapKey

        public java.util.List<DatabaseField> getIdentityFieldsForMapKey()
        INTERNAL: Return the fields that make up the identity of the mapped object. For mappings with a primary key, it will be the set of fields in the primary key. For mappings without a primary key it will likely be all the fields.
        Specified by:
        getIdentityFieldsForMapKey in interface MapKeyMapping
        Returns:
      • getNullValue

        public java.lang.Object getNullValue()
        PUBLIC: Allow for the value used for null to be specified. This can be used to convert database null values to application specific values, when null values are not allowed by the application (such as in primitives). Note: the default value for NULL is used on reads, writes, and query SQL generation
      • getAdditionalSelectionCriteriaForMapKey

        public Expression getAdditionalSelectionCriteriaForMapKey()
        INTERNAL: Return the selection criteria necessary to select the target object when this mapping is a map key. DirectMappings do not need any additional selection criteria when they are map keys.
        Specified by:
        getAdditionalSelectionCriteriaForMapKey in interface MapKeyMapping
        Returns:
      • getTargetVersionOfSourceObject

        public java.lang.Object getTargetVersionOfSourceObject​(java.lang.Object object,
                                                               java.lang.Object parent,
                                                               MergeManager mergeManager,
                                                               AbstractSession targetSession)
        INTERNAL: If required, get the targetVersion of the source object from the merge manager. Used with MapKeyContainerPolicy to abstract getting the target version of a source key.
        Specified by:
        getTargetVersionOfSourceObject in interface MapKeyMapping
        Returns:
      • getMapKeyTargetType

        public java.lang.Class getMapKeyTargetType()
        INTERNAL: Return the class this key mapping maps or the descriptor for it
        Specified by:
        getMapKeyTargetType in interface MapKeyMapping
        Returns:
      • getWeight

        public java.lang.Integer getWeight()
        INTERNAL: Return the weight of the mapping, used to sort mappings to ensure that DirectToField Mappings get merged first
        Overrides:
        getWeight in class DatabaseMapping
      • 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
      • internalBuildChangeRecord

        public ChangeRecord internalBuildChangeRecord​(java.lang.Object newValue,
                                                      java.lang.Object oldValue,
                                                      ObjectChangeSet owner)
        INTERNAL: Build a change record.
      • iterateOnMapKey

        public void iterateOnMapKey​(DescriptorIterator iterator,
                                    java.lang.Object element)
        INTERNAL: Called when iterating through descriptors to handle iteration on this mapping when it is used as a MapKey.
        Specified by:
        iterateOnMapKey in interface MapKeyMapping
      • mergeIntoObject

        public void mergeIntoObject​(java.lang.Object target,
                                    boolean isTargetUnInitialized,
                                    java.lang.Object source,
                                    MergeManager mergeManager,
                                    AbstractSession targetSession)
        INTERNAL: Merge changes from the source to the target object. This merge is only called when a changeSet for the target does not exist or the target is uninitialized
        Specified by:
        mergeIntoObject in class DatabaseMapping
      • requiresDataModificationEventsForMapKey

        public boolean requiresDataModificationEventsForMapKey()
        INTERNAL: Return whether this mapping requires extra queries to update the rows if it is used as a key in a map. This will typically be true if there are any parts to this mapping that are not read-only.
        Specified by:
        requiresDataModificationEventsForMapKey in interface MapKeyMapping
      • setAttributeClassification

        public void setAttributeClassification​(java.lang.Class attributeClassification)
        PUBLIC: Some databases do not properly support all of the base data types. For these databases, the base data type must be explicitly specified in the mapping to tell EclipseLink to force the instance variable value to that data type
      • setAttributeClassificationName

        public void setAttributeClassificationName​(java.lang.String attributeClassificationName)
        INTERNAL: Set the name of the class for MW usage.
      • setNullValue

        public void setNullValue​(java.lang.Object nullValue)
        PUBLIC: Allow for the value used for null to be specified. This can be used to convert database null values to application specific values, when null values are not allowed by the application (such as in primitives). Note: the default value for NULL is used on reads, writes, and query SQL generation
      • updateChangeRecord

        public void updateChangeRecord​(java.lang.Object clone,
                                       java.lang.Object newValue,
                                       java.lang.Object oldValue,
                                       ObjectChangeSet objectChangeSet,
                                       UnitOfWorkImpl uow)
        INTERNAL: Either create a new change record or update with the new value. This is used by attribute change tracking.
        Overrides:
        updateChangeRecord in class DatabaseMapping
      • isCloningRequired

        public boolean isCloningRequired()
        INTERNAL: Return if this mapping requires its attribute value to be cloned.
        Overrides:
        isCloningRequired in class DatabaseMapping
      • unwrapKey

        public java.lang.Object unwrapKey​(java.lang.Object key,
                                          AbstractSession session)
        INTERNAL: Allow the key mapping to unwrap the object.
        Specified by:
        unwrapKey in interface MapKeyMapping
        Returns:
      • wrapKey

        public java.lang.Object wrapKey​(java.lang.Object key,
                                        AbstractSession session)
        INTERNAL: Allow the key mapping to wrap the object.
        Specified by:
        wrapKey in interface MapKeyMapping
        Returns:
      • buildShallowOriginalFromRow

        public void buildShallowOriginalFromRow​(AbstractRecord databaseRow,
                                                java.lang.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
      • valueFromRow

        public java.lang.Object valueFromRow​(AbstractRecord row,
                                             JoinedAttributeManager joinManager,
                                             ObjectBuildingQuery query,
                                             CacheKey cacheKey,
                                             AbstractSession executionSession,
                                             boolean isTargetProtected,
                                             java.lang.Boolean[] wasCacheUsed)
        INTERNAL: Return the mapping's attribute value from the row. The execution session is passed for the case of building a UnitOfWork clone directly from a row, the session set in the query will not know which platform to use for converting the value. Allows the correct session to be passed in.
        Overrides:
        valueFromRow in class DatabaseMapping
      • valueFromResultSet

        public java.lang.Object valueFromResultSet​(java.sql.ResultSet resultSet,
                                                   ObjectBuildingQuery query,
                                                   AbstractSession session,
                                                   DatabaseAccessor accessor,
                                                   java.sql.ResultSetMetaData metaData,
                                                   int columnNumber,
                                                   DatabasePlatform platform)
                                            throws java.sql.SQLException
        INTERNAL: Returns the value for the mapping directly from the result-set. PERF: Used for optimized object building.
        Overrides:
        valueFromResultSet in class DatabaseMapping
        Throws:
        java.sql.SQLException
      • getFieldClassificationClassName

        public java.lang.String getFieldClassificationClassName()
        INTERNAL: Get fieldClassificationClassName. Value usually exist for fields with some kind of embedded converter like @Lob or @Temporal.