Top Description Fields Constructors Methods
org.eclipse.persistence.mappings.foundation

public abstract Class AbstractDirectMapping

extends AbstractColumnMapping
implements MapKeyMapping
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.mappings.foundation.MapKeyMapping, org.eclipse.persistence.mappings.foundation.MapComponentMapping
Known Direct Subclasses
org.eclipse.persistence.oxm.mappings.XMLDirectMapping, org.eclipse.persistence.eis.mappings.EISDirectMapping, org.eclipse.persistence.mappings.DirectToFieldMapping
Imports
java.security.AccessController, .PrivilegedActionException, java.util.*, java.sql.ResultSet, .ResultSetMetaData, .SQLException, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.*, org.eclipse.persistence.expressions.*, org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor, .DatabasePlatform, org.eclipse.persistence.internal.descriptors.*, org.eclipse.persistence.internal.expressions.SQLSelectStatement, org.eclipse.persistence.internal.helper.*, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.queries.ContainerPolicy, .JoinedAttributeManager, .MappedKeyMapContainerPolicy, org.eclipse.persistence.internal.sessions.*, org.eclipse.persistence.mappings.converters.*, org.eclipse.persistence.mappings.querykeys.DirectQueryKey, .QueryKey, org.eclipse.persistence.queries.*, org.eclipse.persistence.sessions.remote.*, org.eclipse.persistence.sessions.CopyGroup, .Project, .Session, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, .PrivilegedClassForName

Purpose: Maps an attribute to the corresponding database field type. The list of field types that are supported by EclipseLink's direct to field mapping is dependent on the relational database being used. A converter can be used to convert between the object and data type if they do not match.
Author
Sati
Since
TopLink/Java 1.0
See Also
Converter, ObjectTypeConverter, TypeConversionConverter, SerializedObjectConverter, ClassInstanceConverter

Field Summary

Modifier and TypeField and Description
protected transient Class<?>
attributeClassification

To specify the conversion type

protected String
protected transient Class<?>
attributeObjectClassification

PERF: Also store object class of attribute in case of primitive.

protected boolean
bypassDefaultNullValueCheck

PERF: Avoid default null value conversion check if not default null value set in conversion manager.

protected String
protected Boolean
isMutable

PERF: Indicates if this mapping's attribute is a simple atomic value and cannot be modified, only replaced.

protected DatabaseTable
protected transient Object
nullValue

Support specification of the value to use for null.

Inherited from org.eclipse.persistence.mappings.foundation.AbstractColumnMapping:
converterconverterClassNamefieldisInsertableisUpdatable

Constructor Summary

AccessConstructor and Description
protected
AbstractDirectMapping()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public void
addAdditionalFieldsToQuery(ReadQuery selectionQuery, Expression baseExpression)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.addAdditionalFieldsToQuery.

INTERNAL: Used when initializing queries for mappings that use a Map.
public void
addFieldsForMapKey(AbstractRecord joinRow)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.addFieldsForMapKey.

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.
public void
addKeyToDeletedObjectsList(Object object, Map<K, V> deletedObjects)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.addKeyToDeletedObjectsList.

INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy.
public void
buildBackupClone(Object
TODO
clone
,
Object
TODO
backup
,
UnitOfWorkImpl
TODO
unitOfWork
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.buildBackupClone.

INTERNAL: Clone the attribute from the clone and assign it to the backup.
public ChangeRecord
buildChangeRecord(Object clone, ObjectChangeSet owner, AbstractSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.buildChangeRecord.

INTERNAL: Directly build a change record without comparison
public void
buildClone(Object
TODO
original
,
CacheKey
TODO
cacheKey
,
Object
TODO
clone
,
Integer
TODO
refreshCascade
,
AbstractSession
TODO
cloningSession
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.buildClone.

INTERNAL: Clone the attribute from the original and assign it to the clone.
public void
buildCloneFromRow(AbstractRecord
TODO
databaseRow
,
JoinedAttributeManager
TODO
joinManager
,
Object
TODO
clone
,
CacheKey
TODO
sharedCacheKey
,
ObjectBuildingQuery
TODO
sourceQuery
,
UnitOfWorkImpl
TODO
unitOfWork
,
AbstractSession
TODO
executionSession
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.buildCloneFromRow.

INTERNAL: Extract value from the row and set the attribute to this value in the working copy clone.
public void
buildCloneValue(Object original, Object clone, AbstractSession session)

INTERNAL: Clone the attribute from the original and assign it to the clone.

protected Object
buildCloneValue(Object attributeValue, AbstractSession session)

INTERNAL: Clone the actual value represented by this mapping.

public void
buildCopy(Object
TODO
copy
,
Object
TODO
original
,
CopyGroup
TODO
group
)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.buildCopy.

INTERNAL: Copy of the attribute of the object.
public Object
buildElementClone(Object attributeValue, Object parent, CacheKey cacheKey, Integer refreshCascade, AbstractSession cloningSession, boolean isExisting, boolean isFromSharedCache)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.buildElementClone.

Build a clone of the given element in a unitOfWork.
public Expression
buildExpression(Object
TODO
queryObject
,
QueryByExamplePolicy
TODO
policy
,
Expression
TODO
expressionBuilder
,
Map<K, V>
TODO
processedObjects
,
AbstractSession
TODO
session
)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.buildExpression.

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.
public ReadQuery
public void
buildShallowOriginalFromRow(AbstractRecord
TODO
databaseRow
,
Object
later the input to buildCloneFromRow
original
,
JoinedAttributeManager
TODO
joinManager
,
ObjectBuildingQuery
TODO
query
,
AbstractSession
TODO
executionSession
)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.buildShallowOriginalFromRow.

INTERNAL: Builds a shallow original object.
public void
cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map<K, V> newObjects, Map<K, V> unregisteredExistingObjects, Map<K, V> visitedObjects, UnitOfWorkImpl uow, boolean getAttributeValueFromObject, Set<E> cascadeErrors)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.cascadeDiscoverAndPersistUnregisteredNewObjects.

INTERNAL: Cascade discover and persist new objects during commit to the map key.
public void
cascadePerformRemoveIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects, boolean getAttributeValueFromObject)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.cascadePerformRemoveIfRequired.

INTERNAL: Cascade perform delete through mappings that require the cascade.
public void
cascadePerformRemoveIfRequired(Object
TODO
object
,
UnitOfWorkImpl
TODO
uow
,
Map<K, V>
TODO
visitedObjects
)

Overrides org.eclipse.persistence.mappings.foundation.AbstractColumnMapping.cascadePerformRemoveIfRequired.

INTERNAL: Cascade perform delete through mappings that require the cascade.
public void
cascadeRegisterNewIfRequired(Object object, UnitOfWorkImpl uow, Map<K, V> visitedObjects, boolean getAttributeValueFromObject)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.cascadeRegisterNewIfRequired.

INTERNAL: Cascade registerNew for Create through mappings that require the cascade.
public void
cascadeRegisterNewIfRequired(Object
TODO
object
,
UnitOfWorkImpl
TODO
uow
,
Map<K, V>
TODO
visitedObjects
)

Overrides org.eclipse.persistence.mappings.foundation.AbstractColumnMapping.cascadeRegisterNewIfRequired.

INTERNAL: Cascade registerNew for Create through mappings that require the cascade.
public ChangeRecord
compareForChange(Object
TODO
clone
,
Object
TODO
backUp
,
ObjectChangeSet
TODO
owner
,
AbstractSession
TODO
session
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.compareForChange.

INTERNAL: Compare the clone and backup clone values and return a change record if the value changed.
public boolean
compareObjects(Object
TODO
firstObject
,
Object
TODO
secondObject
,
AbstractSession
TODO
session
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.compareObjects.

INTERNAL: Compare the attributes belonging to this mapping for the objects.
protected boolean
compareObjectValues(Object firstValue, Object secondValue, AbstractSession session)

INTERNAL: Compare the attribute values.

public void
convertClassNamesToClasses(ClassLoader
TODO
classLoader
)

Overrides org.eclipse.persistence.mappings.foundation.AbstractColumnMapping.convertClassNamesToClasses.

INTERNAL: Convert all the class-name-based settings in this mapping to actual class-based settings This method is implemented by subclasses as necessary.
public Object
createMapComponentFromJoinedRow(AbstractRecord dbRow, JoinedAttributeManager joinManger, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.createMapComponentFromJoinedRow.

INTERNAL Called when a DatabaseMapping is used to map the key in a collection and a join query is executed.
public Object
createMapComponentFromRow(AbstractRecord dbRow, ObjectBuildingQuery query, CacheKey parentCacheKey, AbstractSession session, boolean isTargetProtected)

Implements org.eclipse.persistence.mappings.foundation.MapComponentMapping.createMapComponentFromRow.

INTERNAL Called when a DatabaseMapping is used to map the key in a collection.
public List<Object>
createMapComponentsFromSerializableKeyInfo(Object[] keyInfo, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.createMapComponentsFromSerializableKeyInfo.

INTERNAL: Create an instance of the Key object from the key information extracted from the map.
public QueryKey
createQueryKeyForMapKey()

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.createQueryKeyForMapKey.

INTERNAL: Create a query key that links to the map key.
public Object
createSerializableMapKeyInfo(Object key, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.createSerializableMapKeyInfo.

INTERNAL: Creates the Array of simple types used to recreate this map.
public Object
createStubbedMapComponentFromSerializableKeyInfo(Object keyInfo, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.createStubbedMapComponentFromSerializableKeyInfo.

INTERNAL: Create an instance of the Key object from the key information extracted from the map.
public void
deleteMapKey(Object objectDeleted, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.deleteMapKey.

INTERNAL: For mappings used as MapKeys in MappedKeyContainerPolicy, Delete the passed object if necessary.
public Map<K, V>
extractIdentityFieldsForQuery(Object object, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.extractIdentityFieldsForQuery.

INTERNAL: Extract the fields for the Map key from the object to use in a query.
public Expression
getAdditionalSelectionCriteriaForMapKey()

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getAdditionalSelectionCriteriaForMapKey.

INTERNAL: Return the selection criteria necessary to select the target object when this mapping is a map key.
public List<DatabaseTable>
getAdditionalTablesForJoinQuery()

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getAdditionalTablesForJoinQuery.

INTERNAL: Return any tables that will be required when this mapping is used as part of a join query.
public List<DatabaseField>
public Class<?>
getAttributeClassification()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.getAttributeClassification.

PUBLIC: Some databases do not properly support all of the base data types.
public String
getAttributeClassificationName()

INTERNAL: Return the class name of the attribute type.

public Class<?>
getFieldClassification(DatabaseField fieldToClassify)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.getFieldClassification.

INTERNAL: Return the classification for the field contained in the mapping.
public Class<?>
getFieldClassification()

ADVANCED: Return the class type of the field value.

public String
getFieldClassificationClassName()

INTERNAL: Get fieldClassificationClassName.

public String
getFieldName()

PUBLIC: Name of the field this mapping represents.

public Object
getFieldValue(Object attributeValue, AbstractSession session)

Implements abstract org.eclipse.persistence.mappings.foundation.AbstractColumnMapping.getFieldValue.

INTERNAL: Convert the attribute value to a field value.
public Map<DatabaseField, DatabaseField>
getForeignKeyFieldsForMapKey()

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getForeignKeyFieldsForMapKey.

INTERNAL: Return a Map of any foreign keys defined within the the MapKey.
public List<DatabaseField>
getIdentityFieldsForMapKey()

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getIdentityFieldsForMapKey.

INTERNAL: Return the fields that make up the identity of the mapped object.
public Class<?>
getMapKeyTargetType()

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getMapKeyTargetType.

INTERNAL: Return the class this key mapping maps or the descriptor for it
public ObjectLevelReadQuery
getNestedJoinQuery(JoinedAttributeManager joinManager, ObjectLevelReadQuery query, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getNestedJoinQuery.

INTERNAL: Return the query that is used when this mapping is part of a joined relationship This method is used when this mapping is used to map the key in a Map.
public Object
getNullValue()

PUBLIC: Allow for the value used for null to be specified.

public Object
getObjectValue(Object fieldValue, Session session)

Implements abstract org.eclipse.persistence.mappings.foundation.AbstractColumnMapping.getObjectValue.

INTERNAL: Allows for subclasses to convert the attribute value.
public Object
getObjectValueWithoutClassCheck(Object fieldValue, Session session)

INTERNAL: Same as getObjectValue method, but without checking fieldValue's class.

public ClassDescriptor
getReferenceDescriptor()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.getReferenceDescriptor.

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getReferenceDescriptor.

INTERNAL: Get the descriptor for this mapping This method is potentially called when this mapping is used as a map key and will return null since direct mappings do not have reference descriptors.
public Object
getTargetVersionOfSourceObject(Object object, Object parent, MergeManager mergeManager, AbstractSession targetSession)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.getTargetVersionOfSourceObject.

INTERNAL: If required, get the targetVersion of the source object from the merge manager.
public Integer
getWeight()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.getWeight.

INTERNAL: Return the weight of the mapping, used to sort mappings to ensure that DirectToField Mappings get merged first
public void
initialize(AbstractSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.initialize.

INTERNAL: The mapping is initialized with the given session.
public ChangeRecord
internalBuildChangeRecord(Object newValue, Object oldValue, ObjectChangeSet owner)

INTERNAL: Build a change record.

public boolean
public boolean
isChangeTrackingSupported(Project project)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.isChangeTrackingSupported.

INTERNAL: Return if this mapping supports change tracking.
public boolean
isCloningRequired()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.isCloningRequired.

INTERNAL: Return if this mapping requires its attribute value to be cloned.
public boolean
public boolean
isMutable()

PUBLIC: Return true if the attribute for this mapping is a simple atomic value that cannot be modified, only replaced.

public void
iterateOnMapKey(DescriptorIterator iterator, Object element)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.iterateOnMapKey.

INTERNAL: Called when iterating through descriptors to handle iteration on this mapping when it is used as a MapKey.
public void
mergeChangesIntoObject(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager, AbstractSession targetSession)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.mergeChangesIntoObject.

INTERNAL: Merge changes from the source to the target object.
public void
mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager, AbstractSession targetSession)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.mergeIntoObject.

INTERNAL: Merge changes from the source to the target object.
public void
postInitializeMapKey(MappedKeyMapContainerPolicy policy)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.postInitializeMapKey.

INTERNAL: Making any mapping changes necessary to use a the mapping as a map key after initializing the mapping.
public void
preInitialize(AbstractSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.preInitialize.

INTERNAL: Initialize the attribute classification.
public void
preinitializeMapKey(DatabaseTable table)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.preinitializeMapKey.

INTERNAL: Making any mapping changes necessary to use a the mapping as a map key prior to initializing the mapping.
public void
remoteInitialization(DistributedSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.remoteInitialization.

INTERNAL: Once descriptors are serialized to the remote session.
public boolean
requiresDataModificationEventsForMapKey()

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.requiresDataModificationEventsForMapKey.

INTERNAL: Return whether this mapping requires extra queries to update the rows if it is used as a key in a map.
public void
setAttributeClassification(Class<?> attributeClassification)

PUBLIC: Some databases do not properly support all of the base data types.

public void
setAttributeClassificationName(String attributeClassificationName)

INTERNAL: Set the name of the class for MW usage.

public void
setFieldClassification(Class<?> fieldType)

ADVANCED: Set the class type of the field value.

public void
setFieldClassificationClassName(String className)

INTERNAL: Set the name of the class that will be used for setFieldClassification and deploy time Used internally by JPA deployment.

public void
setFieldType(int jdbcType)

ADVANCED: Set the JDBC type of the field value.

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.

public void
setNullValue(Object nullValue)

PUBLIC: Allow for the value used for null to be specified.

public String
public Object
unwrapKey(Object key, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.unwrapKey.

INTERNAL: Allow the key mapping to unwrap the object.
public void
updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.updateChangeRecord.

INTERNAL: Either create a new change record or update with the new value.
public void
public Object
valueFromObject(Object
TODO
object
,
DatabaseField
TODO
field
,
AbstractSession
TODO
session
)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.valueFromObject.

INTERNAL: Get the value from the object for this mapping.
public Object
valueFromResultSet(ResultSet resultSet, ObjectBuildingQuery query, AbstractSession session, DatabaseAccessor accessor, ResultSetMetaData metaData, int columnNumber, DatabasePlatform platform)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.valueFromResultSet.

INTERNAL: Returns the value for the mapping directly from the result-set.
public Object
valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.valueFromRow.

INTERNAL: Return the mapping's attribute value from the row.
public Object
wrapKey(Object key, AbstractSession session)

Implements org.eclipse.persistence.mappings.foundation.MapKeyMapping.wrapKey.

INTERNAL: Allow the key mapping to wrap the object.
public void
writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session, DatabaseMapping.WriteType writeType)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.writeFromObjectIntoRow.

INTERNAL: Get a value from the object and set that in the respective field of the row.
public void
writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord databaseRow)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.writeFromObjectIntoRowForUpdate.

INTERNAL: Write the attribute value from the object to the row for update.
public void
writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session, DatabaseMapping.WriteType writeType)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.writeFromObjectIntoRowWithChangeRecord.

INTERNAL: Get a value from the object and set that in the respective field of the row.
public void
writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.writeInsertFieldsIntoRow.

INTERNAL: Write fields needed for insert into the template for with null values.
public void
writeUpdateFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.writeUpdateFieldsIntoRow.

INTERNAL: Write fields needed for update into the template for with null values.
protected abstract void
Inherited from org.eclipse.persistence.mappings.foundation.AbstractColumnMapping:
clonecollectFieldsfixObjectReferencesgetConvertergetFieldhasConverterisAbstractColumnMappingisInsertableisUpdatableiteratesetConvertersetConverterClassNamesetField