public abstract class AbstractDirectMapping extends DatabaseMapping
Converter
,
ObjectTypeConverter
,
TypeConversionConverter
,
SerializedObjectConverter
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected Class |
attributeClassification
To specify the conversion type
|
protected String |
attributeClassificationName |
protected Class |
attributeObjectClassification
PERF: Also store object class of attribute in case of primitive.
|
protected Converter |
converter
Allows user defined conversion between the object attribute value and the database value.
|
protected DatabaseField |
field
DatabaseField which this mapping represents.
|
protected Boolean |
isMutable
PERF: Indicates if this mapping's attribute is a simple atomic value and cannot be modified, only replaced.
|
protected Object |
nullValue
Support specification of the value to use for null.
|
attributeAccessor, descriptor, fields, isOptional, isReadOnly, isRemotelyInitialized, NO_FIELDS, NO_WEIGHT, primaryKeyMapping, properties, weight, WEIGHT_1
Constructor and Description |
---|
AbstractDirectMapping()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
buildBackupClone(Object clone,
Object backup,
UnitOfWorkImpl unitOfWork)
INTERNAL:
Clone the attribute from the clone and assign it to the backup.
|
ChangeRecord |
buildChangeRecord(Object clone,
ObjectChangeSet owner,
AbstractSession session)
INTERNAL:
Directly build a change record without comparison
|
void |
buildClone(Object original,
Object clone,
UnitOfWorkImpl unitOfWork,
JoinedAttributeManager joinedAttributeManager)
INTERNAL:
Clone the attribute from the original and assign it to the clone.
|
void |
buildCloneFromRow(AbstractRecord databaseRow,
JoinedAttributeManager joinManager,
Object clone,
ObjectBuildingQuery sourceQuery,
UnitOfWorkImpl unitOfWork,
AbstractSession executionSession)
INTERNAL:
Extract value from the row and set the attribute to this value in the
working copy clone.
|
void |
buildCloneValue(Object original,
Object clone,
AbstractSession session)
INTERNAL:
Clone the attribute from the original and assign it to the clone.
|
void |
buildCopy(Object copy,
Object original,
ObjectCopyingPolicy policy)
INTERNAL:
Copy of the attribute of the object.
|
void |
buildShallowOriginalFromRow(AbstractRecord databaseRow,
Object original,
ObjectBuildingQuery query,
AbstractSession executionSession)
INTERNAL:
Builds a shallow original object.
|
void |
cascadePerformRemoveIfRequired(Object object,
UnitOfWorkImpl uow,
IdentityHashtable visitedObjects)
INTERNAL:
Cascade perform delete through mappings that require the cascade
|
void |
cascadeRegisterNewIfRequired(Object object,
UnitOfWorkImpl uow,
IdentityHashtable visitedObjects)
INTERNAL:
Cascade registerNew for Create through mappings that require the cascade
|
Object |
clone()
INTERNAL:
The mapping clones itself to create deep copy.
|
protected Vector<DatabaseField> |
collectFields()
Returns the field this mapping represents.
|
ChangeRecord |
compareForChange(Object clone,
Object backUp,
ObjectChangeSet owner,
AbstractSession session)
INTERNAL:
Compare the clone and backup clone values and return a change record if the value changed.
|
boolean |
compareObjects(Object firstObject,
Object secondObject,
AbstractSession session)
INTERNAL:
Compare the attributes belonging to this mapping for the objects.
|
void |
convertClassNamesToClasses(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.
|
Class |
getAttributeClassification()
PUBLIC:
Some databases do not properly support all of the base data types.
|
String |
getAttributeClassificationName() |
Object |
getAttributeValue(Object fieldValue,
AbstractSession session)
INTERNAL:
Allows for subclasses to convert the attribute value.
|
Converter |
getConverter()
PUBLIC:
Return the converter on the mapping.
|
DatabaseField |
getField()
INTERNAL:
Returns the field which this mapping represents.
|
Class |
getFieldClassification()
ADVANCED:
Return the class type of the field value.
|
Class |
getFieldClassification(DatabaseField fieldToClassify)
INTERNAL:
Return the classifiction for the field contained in the mapping.
|
String |
getFieldName()
PUBLIC:
Name of the field this mapping represents.
|
Object |
getFieldValue(Object attributeValue,
AbstractSession session)
INTERNAL:
Convert the attribute value to a field value.
|
Object |
getNullValue()
PUBLIC:
Allow for the value used for null to be specified.
|
Integer |
getWeight()
INTERNAL:
Return the weight of the mapping, used to sort mappings to ensure that
DirectToField Mappings get merged first
|
void |
initialize(AbstractSession session)
INTERNAL:
The mapping is initialized with the given session.
|
ChangeRecord |
internalBuildChangeRecord(Object newValue,
ObjectChangeSet owner)
INTERNAL:
Build a change record
|
boolean |
isAbstractDirectMapping()
INTERNAL:
|
boolean |
isChangeTrackingSupported()
INTERNAL:
Return if this mapping supports change tracking.
|
boolean |
isCloningRequired()
INTERNAL:
Return if this mapping requires its attribute value to be cloned.
|
boolean |
isDirectToFieldMapping()
INTERNAL:
|
boolean |
isMutable()
PUBLIC:
Return true if the attribute for this mapping is a simple atomic value that cannot be modified,
only replaced.
|
void |
iterate(DescriptorIterator iterator)
INTERNAL:
Iterate on the appropriate attribute.
|
void |
mergeChangesIntoObject(Object target,
ChangeRecord changeRecord,
Object source,
MergeManager mergeManager)
INTERNAL:
Merge changes from the source to the target object.
|
void |
mergeIntoObject(Object target,
boolean isTargetUnInitialized,
Object source,
MergeManager mergeManager)
INTERNAL:
Merge changes from the source to the target object.
|
void |
preInitialize(AbstractSession session)
INTERNAL:
Initialize the attribute classification.
|
void |
setAttributeClassification(Class attributeClassification)
PUBLIC:
Some databases do not properly support all of the base data types.
|
void |
setAttributeClassificationName(String attributeClassificationName)
INTERNAL:
Set the name of the class for MW usage.
|
void |
setConverter(Converter converter)
PUBLIC:
Set the converter on the mapping.
|
void |
setField(DatabaseField theField)
ADVANCED:
Set the field in the mapping.
|
void |
setFieldClassification(Class fieldType)
ADVANCED:
Set the class type of the field value.
|
void |
setFieldType(int jdbcType)
ADVANCED:
Set the JDBC type of the field value.
|
void |
setIsMutable(boolean isMutable)
PUBLIC:
Return true if the attribute for this mapping is a simple atomic value that cannot be modified,
only replaced.
|
void |
setNullValue(Object nullValue)
PUBLIC:
Allow for the value used for null to be specified.
|
String |
toString()
INTERNAL:
|
void |
updateChangeRecord(Object clone,
Object newValue,
Object oldValue,
ObjectChangeSet objectChangeSet,
UnitOfWorkImpl uow)
INTERNAL:
Either create a new change record or update with the new value.
|
void |
validateBeforeInitialization(AbstractSession session)
INTERNAL:
Allow for subclasses to perform validation.
|
Object |
valueFromObject(Object object,
DatabaseField field,
AbstractSession session)
INTERNAL:
Get the value from the object for this mapping.
|
Object |
valueFromRow(AbstractRecord row,
JoinedAttributeManager joinManager,
ObjectBuildingQuery query,
AbstractSession executionSession)
INTERNAL:
In the case of building a UnitOfWork clone directly from a row, the
session set in the query will not know which database platform to use
for converting the value.
|
void |
writeFromObjectIntoRow(Object object,
AbstractRecord row,
AbstractSession session)
INTERNAL:
Get a value from the object and set that in the respective field of the row.
|
void |
writeFromObjectIntoRowForUpdate(WriteObjectQuery query,
AbstractRecord aDatabaseRow)
INTERNAL:
Write the attribute value from the object to the row for update.
|
void |
writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord,
AbstractRecord row,
AbstractSession session)
INTERNAL:
Get a value from the object and set that in the respective field of the row.
|
void |
writeInsertFieldsIntoRow(AbstractRecord databaseRow,
AbstractSession session)
INTERNAL:
Write fields needed for insert into the template for with null values.
|
protected abstract void |
writeValueIntoRow(AbstractRecord row,
DatabaseField field,
Object value) |
addToCollectionChangeRecord, buildBackupCloneForPartObject, buildCloneForPartObject, buildObjectJoinExpression, buildObjectJoinExpression, calculateDeferredChanges, cascadeMerge, cloneFields, createUnitOfWorkValueHolder, extractNestedExpressions, getAttributeAccessor, getAttributeName, getAttributeValueFromObject, getContainerPolicy, getDescriptor, getFields, getGetMethodName, getProperties, getProperty, getRealAttributeValueFromObject, getRealCollectionAttributeValueFromObject, getReferenceClassDescriptor, getReferenceDescriptor, getRelationshipPartner, getSetMethodName, hasConstraintDependency, hasDependency, hasInverseConstraintDependency, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAggregateCollectionMapping, isAggregateMapping, isAggregateObjectMapping, isCascadedLockingSupported, isCollectionMapping, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToXMLTypeMapping, isEISMapping, isForeignReferenceMapping, isJoiningSupported, isManyToManyMapping, isNestedTableMapping, isObjectReferenceMapping, isObjectTypeMapping, isOneToManyMapping, isOneToOneMapping, isOptional, isPrimaryKeyMapping, isPrivateOwned, isReadOnly, isReferenceMapping, isRelationalMapping, isRemotelyInitialized, isSerializedObjectMapping, isStructureMapping, isTransformationMapping, isTypeConversionMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, iterateOnRealAttributeValue, performDataModificationEvent, postDelete, postInitialize, postInsert, postUpdate, preDelete, preInsert, prepareCascadeLockingPolicy, preUpdate, readFromRowIntoObject, readFromRowIntoObject, readOnly, readWrite, rehashFieldDependancies, removeFromCollectionChangeRecord, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setDescriptor, setFields, setGetMethodName, setIsOptional, setIsPrimaryKeyMapping, setIsReadOnly, setProperties, setProperty, setRealAttributeValueInObject, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, validateAfterInitialization, valueFromRow, verifyDelete, writeFromAttributeIntoRow, writeFromObjectIntoRowForShallowDelete, writeFromObjectIntoRowForShallowInsert, writeFromObjectIntoRowForShallowInsertWithChangeRecord, writeFromObjectIntoRowForWhereClause, writeUpdateFieldsIntoRow
protected DatabaseField field
protected transient Class attributeClassification
protected transient String attributeClassificationName
protected transient Class attributeObjectClassification
protected Converter converter
protected transient Object nullValue
protected Boolean isMutable
public Converter getConverter()
public void setConverter(Converter converter)
public boolean isMutable()
public void setIsMutable(boolean isMutable)
public void buildBackupClone(Object clone, Object backup, UnitOfWorkImpl unitOfWork)
buildBackupClone
in class DatabaseMapping
public void buildClone(Object original, Object clone, UnitOfWorkImpl unitOfWork, JoinedAttributeManager joinedAttributeManager)
buildClone
in class DatabaseMapping
public void buildCloneValue(Object original, Object clone, AbstractSession session)
public void buildCopy(Object copy, Object original, ObjectCopyingPolicy policy)
buildCopy
in class DatabaseMapping
public void cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, IdentityHashtable visitedObjects)
cascadePerformRemoveIfRequired
in class DatabaseMapping
public void cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, IdentityHashtable visitedObjects)
cascadeRegisterNewIfRequired
in class DatabaseMapping
public Object clone()
clone
in class DatabaseMapping
protected Vector<DatabaseField> collectFields()
collectFields
in class DatabaseMapping
public ChangeRecord compareForChange(Object clone, Object backUp, ObjectChangeSet owner, AbstractSession session)
compareForChange
in class DatabaseMapping
public ChangeRecord buildChangeRecord(Object clone, ObjectChangeSet owner, AbstractSession session)
buildChangeRecord
in class DatabaseMapping
public ChangeRecord internalBuildChangeRecord(Object newValue, ObjectChangeSet owner)
public boolean compareObjects(Object firstObject, Object secondObject, AbstractSession session)
compareObjects
in class DatabaseMapping
public void convertClassNamesToClasses(ClassLoader classLoader)
convertClassNamesToClasses
in class DatabaseMapping
classLoader
- public Class getAttributeClassification()
getAttributeClassification
in class DatabaseMapping
public String getAttributeClassificationName()
public Object getAttributeValue(Object fieldValue, AbstractSession session)
public DatabaseField getField()
getField
in class DatabaseMapping
public boolean isAbstractDirectMapping()
isAbstractDirectMapping
in class DatabaseMapping
public Class getFieldClassification(DatabaseField fieldToClassify)
getFieldClassification
in class DatabaseMapping
public Class getFieldClassification()
public void setFieldClassification(Class fieldType)
public void setFieldType(int jdbcType)
public String getFieldName()
public Object getFieldValue(Object attributeValue, AbstractSession session)
public Object getNullValue()
public Integer getWeight()
getWeight
in class DatabaseMapping
public void preInitialize(AbstractSession session) throws DescriptorException
preInitialize
in class DatabaseMapping
DescriptorException
public void initialize(AbstractSession session) throws DescriptorException
initialize
in class DatabaseMapping
DescriptorException
public boolean isDirectToFieldMapping()
isDirectToFieldMapping
in class DatabaseMapping
public void iterate(DescriptorIterator iterator)
iterate
in class DatabaseMapping
public void mergeChangesIntoObject(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager)
mergeChangesIntoObject
in class DatabaseMapping
public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager)
mergeIntoObject
in class DatabaseMapping
public void setAttributeClassification(Class attributeClassification)
public void setAttributeClassificationName(String attributeClassificationName)
public void setField(DatabaseField theField)
public void setNullValue(Object nullValue)
public String toString()
toString
in class DatabaseMapping
public void updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow)
updateChangeRecord
in class DatabaseMapping
public boolean isChangeTrackingSupported()
isChangeTrackingSupported
in class DatabaseMapping
public boolean isCloningRequired()
isCloningRequired
in class DatabaseMapping
public void validateBeforeInitialization(AbstractSession session) throws DescriptorException
validateBeforeInitialization
in class DatabaseMapping
DescriptorException
public Object valueFromObject(Object object, DatabaseField field, AbstractSession session) throws DescriptorException
valueFromObject
in class DatabaseMapping
DescriptorException
public void buildCloneFromRow(AbstractRecord databaseRow, JoinedAttributeManager joinManager, Object clone, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession)
buildCloneFromRow
in class DatabaseMapping
public void buildShallowOriginalFromRow(AbstractRecord databaseRow, Object original, ObjectBuildingQuery query, AbstractSession executionSession)
buildShallowOriginalFromRow
in class DatabaseMapping
public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession)
valueFromRow
in class DatabaseMapping
row
- query
- executionSession
- public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session)
writeFromObjectIntoRow
in class DatabaseMapping
protected abstract void writeValueIntoRow(AbstractRecord row, DatabaseField field, Object value)
public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session)
writeFromObjectIntoRowWithChangeRecord
in class DatabaseMapping
public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord aDatabaseRow)
writeFromObjectIntoRowForUpdate
in class DatabaseMapping
public void writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session)
writeInsertFieldsIntoRow
in class DatabaseMapping
Copyright © 2021. All rights reserved.