Class DirectMapMapping

    • Constructor Detail

      • DirectMapMapping

        public DirectMapMapping()
        DirectMapCollectionMapping constructor
    • Method Detail

      • getKeyConverter

        public Converter getKeyConverter()
        PUBLIC: Return the converter on the mapping. A converter can be used to convert between the key's object value and database value.
      • setKeyConverter

        public void setKeyConverter​(Converter keyConverter)
        PUBLIC: Set the converter on the mapping. A converter can be used to convert between the key's object value and database value.
      • setKeyConverterClassName

        public void setKeyConverterClassName​(java.lang.String keyConverterClassName)
        INTERNAL: Set the converter class name on the mapping. Initialized in convertClassNamesToClasses. A converter can be used to convert between the key's object value and database value.
      • addToCollectionChangeRecord

        public void addToCollectionChangeRecord​(java.lang.Object newKey,
                                                java.lang.Object newValue,
                                                ObjectChangeSet objectChangeSet,
                                                UnitOfWorkImpl uow)
                                         throws DescriptorException
        INTERNAL: Add a new value and its change set to the collection change record. This is used by attribute change tracking. If a value has changed then issue a remove first with the key then an add.
        Throws:
        DescriptorException
      • buildCloneForPartObject

        public java.lang.Object buildCloneForPartObject​(java.lang.Object attributeValue,
                                                        java.lang.Object original,
                                                        CacheKey cacheKey,
                                                        java.lang.Object clone,
                                                        AbstractSession cloningSession,
                                                        java.lang.Integer refreshCascade,
                                                        boolean isExisting,
                                                        boolean isFromSharedCache)
        INTERNAL: Require for cloning, the part must be cloned. Ignore the objects, use the attribute value.
        Overrides:
        buildCloneForPartObject in class CollectionMapping
      • calculateDeferredChanges

        public void calculateDeferredChanges​(ChangeRecord changeRecord,
                                             AbstractSession session)
        INTERNAL: Used by AttributeLevelChangeTracking to update a changeRecord with calculated changes as opposed to detected changes. If an attribute can not be change tracked it's changes can be detected through this process.
        Overrides:
        calculateDeferredChanges in class DirectCollectionMapping
      • cascadeDiscoverAndPersistUnregisteredNewObjects

        public void cascadeDiscoverAndPersistUnregisteredNewObjects​(java.lang.Object object,
                                                                    java.util.Map newObjects,
                                                                    java.util.Map unregisteredExistingObjects,
                                                                    java.util.Map visitedObjects,
                                                                    UnitOfWorkImpl uow,
                                                                    java.util.Set cascadeErrors)
        INTERNAL: Cascade discover and persist new objects during commit.
        Overrides:
        cascadeDiscoverAndPersistUnregisteredNewObjects in class DirectCollectionMapping
      • 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.
        Overrides:
        compareObjects in class DirectCollectionMapping
      • convertClassNamesToClasses

        public void convertClassNamesToClasses​(java.lang.ClassLoader classLoader)
        Description copied from class: DirectCollectionMapping
        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 DirectCollectionMapping
      • getDirectKeyField

        public DatabaseField getDirectKeyField()
        INTERNAL:
      • iterateOnRealAttributeValue

        public void iterateOnRealAttributeValue​(DescriptorIterator iterator,
                                                java.lang.Object realAttributeValue)
        INTERNAL: Iterate on the attribute value. The value holder has already been processed. PERF: Avoid iteration if not required.
        Overrides:
        iterateOnRealAttributeValue in class DirectCollectionMapping
      • isDirectMapMapping

        public boolean isDirectMapMapping()
        INTERNAL: Related mapping should implement this method to return true.
        Overrides:
        isDirectMapMapping in class DatabaseMapping
      • mergeChangesIntoObject

        public void mergeChangesIntoObject​(java.lang.Object target,
                                           ChangeRecord changeRecord,
                                           java.lang.Object source,
                                           MergeManager mergeManager,
                                           AbstractSession targetSession)
        INTERNAL: Merge changes from the source to the target object. Because this is a collection mapping, values are added to or removed from the collection based on the changeset.
        Overrides:
        mergeChangesIntoObject in class DirectCollectionMapping
      • recordPrivateOwnedRemovals

        public void recordPrivateOwnedRemovals​(java.lang.Object object,
                                               UnitOfWorkImpl uow)
        INTERNAL: Overridden by mappings that require additional processing of the change record after the record has been calculated.
        Overrides:
        recordPrivateOwnedRemovals in class DirectCollectionMapping
      • removeFromCollectionChangeRecord

        protected void removeFromCollectionChangeRecord​(java.lang.Object newKey,
                                                        java.lang.Object newValue,
                                                        ObjectChangeSet objectChangeSet,
                                                        UnitOfWorkImpl uow)
                                                 throws DescriptorException
        INTERNAL: Remove a value and its change set from the collection change record. This is used by attribute change tracking.
        Throws:
        DescriptorException
      • setDirectKeyField

        public void setDirectKeyField​(DatabaseField keyField)
        INTERNAL:
      • setDirectKeyFieldClassification

        public void setDirectKeyFieldClassification​(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.
      • setDirectKeyFieldClassificationName

        public void setDirectKeyFieldClassificationName​(java.lang.String fieldTypeName)
        ADVANCED: Set the class type name 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 direct key field has been set.
      • setDirectKeyFieldName

        public void setDirectKeyFieldName​(java.lang.String fieldName)
        PUBLIC: Set the direct key field name in the reference table. This is the field that the primitive data value of the Map key is stored in.
      • useMapClass

        public void useMapClass​(java.lang.Class concreteClass)
        PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.

        The default container class is java.util.Hashtable.

        The container class must implements (directly or indirectly) the Map interface.

        Note: Do not use both useMapClass(Class concreteClass), useTransparentMap(). The last use of one of the two methods will override the previous one.

        Overrides:
        useMapClass in class CollectionMapping
      • useTransparentMap

        public void useTransparentMap()
        PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.

        The container class must implement (directly or indirectly) the Map interface.

        Note: Do not use both useMapClass(Class concreteClass), useTransparentMap(). The last use of one of the two methods will override the previous one.

      • setKeyClass

        public void setKeyClass​(java.lang.Class keyClass)
        PUBLIC: This is a helper method to set the key converter to a TypeConversionConverter. This ensures that the key value from the database is converted to the correct Java type. The converter can also be set directly. Note that setting the converter to another converter will overwrite this setting.
      • getKeyClass

        public java.lang.Class getKeyClass()
        PUBLIC: This is a helper method to get the object class from the key converter if it is a TypeConversionConverter. This returns null if not using a TypeConversionConverter key converter.
      • setValueClass

        public void setValueClass​(java.lang.Class valueClass)
        PUBLIC: This is a helper method to set the value converter to a TypeConversionConverter. This ensures that the value from the database is converted to the correct Java type. The converter can also be set directly. Note that setting the converter to another converter will overwrite this setting.
      • simpleAddToCollectionChangeRecord

        public void simpleAddToCollectionChangeRecord​(java.lang.Object referenceKey,
                                                      java.lang.Object objectToAdd,
                                                      ObjectChangeSet changeSet,
                                                      AbstractSession session)
        ADVANCED: This method is used to have an object add to a collection once the changeSet is applied The referenceKey parameter should only be used for direct Maps.
        Overrides:
        simpleAddToCollectionChangeRecord in class DirectCollectionMapping
      • simpleRemoveFromCollectionChangeRecord

        public void simpleRemoveFromCollectionChangeRecord​(java.lang.Object referenceKey,
                                                           java.lang.Object objectToRemove,
                                                           ObjectChangeSet changeSet,
                                                           AbstractSession session)
        ADVANCED: This method is used to have an object removed from a collection once the changeSet is applied The referenceKey parameter should only be used for direct Maps.
        Overrides:
        simpleRemoveFromCollectionChangeRecord in class DirectCollectionMapping
      • getValueClass

        public java.lang.Class getValueClass()
        PUBLIC: This is a helper method to get the object class from the value converter if it is a TypeConversionConverter. This returns null if not using a TypeConversionConverter value converter.