public class OneToOneMapping extends ObjectReferenceMapping implements RelationalMapping
Purpose: One to one mappings are used to represent a pointer references between two java objects. This mappings is usually represented by a single pointer (stored in an instance variable) between the source and target objects. In the relational database tables, these mappings are normally implemented using foreign keys.
| Modifier and Type | Field and Description |
|---|---|
protected Expression |
privateOwnedCriteria |
protected boolean |
shouldVerifyDelete
These are used for non-unit of work modification to check if the value of the 1-1 was changed and a deletion is required.
|
protected java.util.Map<DatabaseField,DatabaseField> |
sourceToTargetKeyFields
Maps the source foreign/primary key fields to the target primary/foreign key fields.
|
protected java.util.Map<DatabaseField,DatabaseField> |
targetToSourceKeyFields
Maps the target primary/foreign key fields to the source foreign/primary key fields.
|
protected boolean |
usesJoining
Indicates whether the referenced object should always be joined on read queries.
|
foreignKeyFields, isForeignKeyRelationshipcascadeMerge, cascadePersist, cascadeRefresh, cascadeRemove, hasCustomSelectionQuery, indirectionPolicy, isPrivateOwned, referenceClass, referenceClassName, referenceDescriptor, relationshipPartner, relationshipPartnerAttributeName, selectionQuery, tempInitSessionattributeAccessor, descriptor, fields, isOptional, isReadOnly, isRemotelyInitialized, NO_FIELDS, NO_WEIGHT, primaryKeyMapping, properties, weight, WEIGHT_1| Constructor and Description |
|---|
OneToOneMapping()
PUBLIC:
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addForeignKeyField(DatabaseField sourceForeignKeyField,
DatabaseField targetPrimaryKeyField)
PUBLIC:
Define the foreign key relationship in the 1-1 mapping.
|
void |
addForeignKeyFieldName(java.lang.String sourceForeignKeyFieldName,
java.lang.String targetPrimaryKeyFieldName)
PUBLIC:
Define the foreign key relationship in the 1-1 mapping.
|
void |
addTargetForeignKeyField(DatabaseField targetForeignKeyField,
DatabaseField sourcePrimaryKeyField)
PUBLIC:
Define the target foreign key relationship in the 1-1 mapping.
|
void |
addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName,
java.lang.String sourcePrimaryKeyFieldName)
PUBLIC:
Define the target foreign key relationship in the 1-1 mapping.
|
Expression |
buildObjectJoinExpression(Expression expression,
Expression argument,
AbstractSession session)
INTERNAL:
Used to allow object level comparisons.
|
Expression |
buildObjectJoinExpression(Expression expression,
java.lang.Object value,
AbstractSession session)
INTERNAL:
Used to allow object level comparisons.
|
Expression |
buildSelectionCriteria()
This method would allow customers to get the potential selection criteria for a mapping
prior to initialization.
|
void |
buildShallowOriginalFromRow(AbstractRecord databaseRow,
java.lang.Object original,
ObjectBuildingQuery query,
AbstractSession executionSession)
INTERNAL:
Builds a shallow original object.
|
java.lang.Object |
clone()
INTERNAL:
This methods clones all the fields and ensures that each collection refers to
the same clones.
|
void |
dontUseJoining()
PUBLIC:
Indicates whether the referenced object should always be joined on read queries.
|
protected java.util.Vector |
extractForeignKeyFromRow(AbstractRecord row,
AbstractSession session)
INTERNAL:
Extract the foreign key value from the source row.
|
protected java.util.Vector |
extractKeyFromReferenceObject(java.lang.Object object,
AbstractSession session)
INTERNAL:
Extract the key value from the reference object.
|
java.util.Vector |
extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row)
INTERNAL:
Return the primary key for the reference object (i.e.
|
java.lang.Class |
getFieldClassification(DatabaseField fieldToClassify)
INTERNAL:
Return the classifiction for the field contained in the mapping.
|
java.util.Vector |
getForeignKeyFieldNames()
PUBLIC:
Return the foreign key field names associated with the mapping.
|
protected java.util.Map |
getForeignKeysToPrimaryKeys()
Return the appropriate hashtable that maps the "foreign keys"
to the "primary keys".
|
java.util.Vector |
getOrderedForeignKeyFields()
INTERNAL:
Return a vector of the foreign key fields in the same order
as the corresponding primary key fields are in their descriptor.
|
protected ClassDescriptor |
getPrimaryKeyDescriptor()
Return the descriptor for whichever side of the
relation has the "primary key".
|
Expression |
getPrivateOwnedCriteria()
INTERNAL:
The private owned criteria is only used outside of the unit of work to compare the previous value of the reference.
|
java.util.Vector |
getSourceToTargetKeyFieldAssociations()
INTERNAL:
Return a collection of the source to target field value associations.
|
java.util.Map<DatabaseField,DatabaseField> |
getSourceToTargetKeyFields()
INTERNAL:
Returns the source keys to target keys fields association.
|
java.util.Map<DatabaseField,DatabaseField> |
getTargetToSourceKeyFields()
INTERNAL:
Returns the target keys to source keys fields association.
|
void |
initialize(AbstractSession session)
INTERNAL:
Initialize the mapping.
|
protected void |
initializeForeignKeys(AbstractSession session)
INTERNAL:
The foreign keys primary keys are stored as database fields in the hashtable.
|
protected void |
initializeForeignKeysWithDefaults(AbstractSession session)
INTERNAL:
The foreign keys primary keys are stored as database fields in the hashtable.
|
protected void |
initializePrivateOwnedCriteria()
INTERNAL:
Selection criteria is created with source foreign keys and target keys.
|
protected void |
initializeSelectionCriteria(AbstractSession session)
INTERNAL:
Selection criteria is created with source foreign keys and target keys.
|
boolean |
isCascadedLockingSupported()
INTERNAL
Return true if this mapping supports cascaded version optimistic locking.
|
boolean |
isJoiningSupported()
INTERNAL:
Return if this mapping support joining.
|
boolean |
isOneToOneMapping()
INTERNAL:
|
boolean |
isRelationalMapping()
INTERNAL:
|
protected java.lang.Object |
readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery)
INTERNAL:
Reads the private owned object.
|
void |
rehashFieldDependancies(AbstractSession session)
INTERNAL:
Rehash any hashtables based on fields.
|
void |
setForeignKeyFieldName(java.lang.String sourceForeignKeyFieldName)
PUBLIC:
Define the foreign key relationship in the 1-1 mapping.
|
void |
setForeignKeyFieldNames(java.util.Vector fieldNames)
PUBLIC:
Return the foreign key field names associated with the mapping.
|
protected void |
setPrivateOwnedCriteria(Expression expression)
INTERNAL:
Private owned criteria is used to verify the deletion of the target.
|
void |
setShouldVerifyDelete(boolean shouldVerifyDelete)
PUBLIC:
Verify delete is used during delete and update on private 1:1's outside of a unit of work only.
|
void |
setSourceToTargetKeyFieldAssociations(java.util.Vector sourceToTargetKeyFieldAssociations)
INTERNAL:
Set a collection of the source to target field associations.
|
void |
setSourceToTargetKeyFields(java.util.Map<DatabaseField,DatabaseField> sourceToTargetKeyFields)
INTERNAL:
Set the source keys to target keys fields association.
|
void |
setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
PUBLIC:
Define the target foreign key relationship in the 1-1 mapping.
|
void |
setTargetToSourceKeyFields(java.util.Map<DatabaseField,DatabaseField> targetToSourceKeyFields)
INTERNAL:
Set the target keys to source keys fields association.
|
void |
setUsesJoining(boolean usesJoining)
PUBLIC:
Indicates whether the referenced object should always be joined on read queries.
|
boolean |
shouldUseJoining()
PUBLIC:
Indicates whether the referenced object should always be joined on read queries.
|
boolean |
shouldVerifyDelete()
PUBLIC:
Verify delete is used during delete and update outside of a unit of work only.
|
void |
useJoining()
PUBLIC:
Indicates whether the referenced object should always be joined on read queries.
|
java.lang.Object |
valueFromObject(java.lang.Object object,
DatabaseField field,
AbstractSession session)
INTERNAL:
Get a value from the object and set that in the respective field of the row.
|
protected java.lang.Object |
valueFromRowInternal(AbstractRecord row,
JoinedAttributeManager joinManager,
AbstractSession executionSession)
INTERNAL:
Return the value of the field from the row or a value holder on the query to obtain the object.
|
protected java.lang.Object |
valueFromRowInternalWithJoin(AbstractRecord row,
JoinedAttributeManager joinManager,
AbstractSession executionSession)
INTERNAL:
If the query used joining or partial attributes, build the target object directly.
|
void |
writeFromAttributeIntoRow(java.lang.Object attribute,
AbstractRecord row,
AbstractSession session)
INTERNAL:
A subclass should implement this method if it wants different behaviour.
|
void |
writeFromObjectIntoRow(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
INTERNAL:
Get a value from the object and set that in the respective field of the row.
|
void |
writeFromObjectIntoRowForShallowDelete(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
INTERNAL:
This row is built for shallow update which happens in case of bidirectional deletes.
|
void |
writeFromObjectIntoRowForShallowInsert(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
INTERNAL:
This row is built for shallow insert which happens in case of bidirectional inserts.
|
void |
writeFromObjectIntoRowForShallowInsertWithChangeRecord(ChangeRecord ChangeRecord,
AbstractRecord databaseRow,
AbstractSession session)
INTERNAL:
This row is built for shallow insert which happens in case of bidirectional inserts.
|
protected void |
writeFromObjectIntoRowForShallowOperation(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
INTERNAL:
This row is built for shallow insert or delete which happens in case of bidirectional relationships.
|
void |
writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord,
AbstractRecord databaseRow,
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.
|
buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildCopy, cacheKeysAreEqual, cascadePerformRemoveIfRequired, cascadeRegisterNewIfRequired, collectFields, compareForChange, compareObjectsWithoutPrivateOwned, compareObjectsWithPrivateOwned, createUnitOfWorkValueHolder, extractPrimaryKeyRowForSourceObject, extractPrimaryKeysForReferenceObject, extractPrimaryKeysFromRealReferenceObject, getDescriptorForTarget, getForeignKeyFields, getPrimaryKeyForObject, getRealAttributeValueFromObject, hasConstraintDependency, insert, internalBuildChangeRecord, isChangeTrackingSupported, isForeignKeyRelationship, isObjectReferenceMapping, iterateOnRealAttributeValue, mergeChangesIntoObject, mergeIntoObject, postDelete, postInsert, postUpdate, preDelete, preInsert, preUpdate, setForeignKeyFields, setIsForeignKeyRelationship, setNewValueInChangeRecord, update, updateChangeRecord, verifyDelete, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowForWhereClausebuildBackupClone, buildClone, buildCloneFromRow, compareObjects, convertClassNamesToClasses, dontDoMerge, dontUseIndirection, getAttributeValueFromObject, getAttributeValueWithClonedValueHolders, getIndirectionPolicy, getJoinCriteria, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getRelationshipPartner, getRelationshipPartnerAttributeName, getSelectionCriteria, getSelectionQuery, getTempSession, hasCustomSelectionQuery, initializeReferenceDescriptor, initializeSelectionQuery, isAttributeValueInstantiated, isCascadeMerge, isCascadePersist, isCascadeRefresh, isCascadeRemove, isForeignReferenceMapping, isPrivateOwned, iterate, prepareHistoricalQuery, prepareNestedJoins, privateOwnedRelationship, setCascadeAll, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setHasCustomSelectionQuery, setIndirectionPolicy, setIsPrivateOwned, setRealAttributeValueInObject, setReferenceClass, setReferenceClassName, setReferenceDescriptor, setRelationshipPartner, setRelationshipPartnerAttributeName, setSelectionCall, setSelectionCriteria, setSelectionQuery, setSelectionSQLString, setTempSession, setUsesIndirection, shouldInitializeSelectionCriteria, shouldMergeCascadeParts, shouldMergeCascadeReference, shouldObjectModifyCascadeToParts, shouldObjectModifyCascadeToPartsForPreDelete, shouldUseValueFromRowWithJoin, trimRowForJoin, trimRowForJoin, useBasicIndirection, usesIndirection, useWeavedIndirection, validateBeforeInitialization, valueFromRowaddToCollectionChangeRecord, calculateDeferredChanges, cascadeMerge, cloneFields, extractNestedExpressions, getAttributeAccessor, getAttributeClassification, getAttributeName, getContainerPolicy, getDescriptor, getField, getFields, getGetMethodName, getProperties, getProperty, getRealCollectionAttributeValueFromObject, getReferenceClassDescriptor, getSetMethodName, getWeight, hasDependency, hasInverseConstraintDependency, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateMapping, isAggregateObjectMapping, isCloningRequired, isCollectionMapping, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isManyToManyMapping, isNestedTableMapping, isObjectTypeMapping, isOneToManyMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isReferenceMapping, isRemotelyInitialized, isSerializedObjectMapping, isStructureMapping, isTransformationMapping, isTypeConversionMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, isXMLMapping, performDataModificationEvent, postInitialize, preInitialize, prepareCascadeLockingPolicy, readFromRowIntoObject, readFromRowIntoObject, readOnly, readWrite, removeFromCollectionChangeRecord, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setDescriptor, setFields, setGetMethodName, setIsOptional, setIsPrimaryKeyMapping, setIsReadOnly, setProperties, setProperty, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, toString, validateAfterInitialization, valueFromRow, writeUpdateFieldsIntoRowprotected java.util.Map<DatabaseField,DatabaseField> sourceToTargetKeyFields
protected java.util.Map<DatabaseField,DatabaseField> targetToSourceKeyFields
protected boolean shouldVerifyDelete
protected transient Expression privateOwnedCriteria
protected boolean usesJoining
public boolean isRelationalMapping()
isRelationalMapping in class DatabaseMappingpublic void addForeignKeyField(DatabaseField sourceForeignKeyField, DatabaseField targetPrimaryKeyField)
public void addForeignKeyFieldName(java.lang.String sourceForeignKeyFieldName,
java.lang.String targetPrimaryKeyFieldName)
public void addTargetForeignKeyField(DatabaseField targetForeignKeyField, DatabaseField sourcePrimaryKeyField)
public void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName,
java.lang.String sourcePrimaryKeyFieldName)
public Expression buildObjectJoinExpression(Expression expression, java.lang.Object value, AbstractSession session)
buildObjectJoinExpression in class DatabaseMappingpublic Expression buildObjectJoinExpression(Expression expression, Expression argument, AbstractSession session)
buildObjectJoinExpression in class DatabaseMappingpublic java.lang.Object clone()
clone in class ForeignReferenceMappingpublic void dontUseJoining()
protected java.util.Vector extractForeignKeyFromRow(AbstractRecord row, AbstractSession session)
protected java.util.Vector extractKeyFromReferenceObject(java.lang.Object object,
AbstractSession session)
public java.util.Vector extractPrimaryKeysForReferenceObjectFromRow(AbstractRecord row)
extractPrimaryKeysForReferenceObjectFromRow in class ObjectReferenceMappingpublic java.lang.Class getFieldClassification(DatabaseField fieldToClassify) throws DescriptorException
getFieldClassification in class DatabaseMappingDescriptorExceptionpublic java.util.Vector getForeignKeyFieldNames()
protected java.util.Map getForeignKeysToPrimaryKeys()
public java.util.Vector getOrderedForeignKeyFields()
protected ClassDescriptor getPrimaryKeyDescriptor()
public Expression getPrivateOwnedCriteria()
public java.util.Vector getSourceToTargetKeyFieldAssociations()
public java.util.Map<DatabaseField,DatabaseField> getSourceToTargetKeyFields()
public java.util.Map<DatabaseField,DatabaseField> getTargetToSourceKeyFields()
public void initialize(AbstractSession session) throws DescriptorException
initialize in class ForeignReferenceMappingDescriptorExceptionprotected void initializeForeignKeys(AbstractSession session)
protected void initializeForeignKeysWithDefaults(AbstractSession session)
protected void initializePrivateOwnedCriteria()
protected void initializeSelectionCriteria(AbstractSession session)
public Expression buildSelectionCriteria()
public void buildShallowOriginalFromRow(AbstractRecord databaseRow, java.lang.Object original, ObjectBuildingQuery query, AbstractSession executionSession)
buildShallowOriginalFromRow in class DatabaseMappingpublic boolean isOneToOneMapping()
isOneToOneMapping in class DatabaseMappingprotected java.lang.Object readPrivateOwnedForObject(ObjectLevelModifyQuery modifyQuery) throws DatabaseException
readPrivateOwnedForObject in class ObjectReferenceMappingDatabaseExceptionpublic void rehashFieldDependancies(AbstractSession session)
rehashFieldDependancies in class DatabaseMappingpublic void setForeignKeyFieldName(java.lang.String sourceForeignKeyFieldName)
public void setForeignKeyFieldNames(java.util.Vector fieldNames)
protected void setPrivateOwnedCriteria(Expression expression)
public void setShouldVerifyDelete(boolean shouldVerifyDelete)
public void setSourceToTargetKeyFieldAssociations(java.util.Vector sourceToTargetKeyFieldAssociations)
public void setSourceToTargetKeyFields(java.util.Map<DatabaseField,DatabaseField> sourceToTargetKeyFields)
public void setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
public void setTargetToSourceKeyFields(java.util.Map<DatabaseField,DatabaseField> targetToSourceKeyFields)
public void setUsesJoining(boolean usesJoining)
public boolean shouldUseJoining()
public boolean shouldVerifyDelete()
public boolean isCascadedLockingSupported()
isCascadedLockingSupported in class DatabaseMappingpublic boolean isJoiningSupported()
isJoiningSupported in class DatabaseMappingpublic void useJoining()
public void writeFromAttributeIntoRow(java.lang.Object attribute,
AbstractRecord row,
AbstractSession session)
writeFromAttributeIntoRow in class DatabaseMappingpublic java.lang.Object valueFromObject(java.lang.Object object,
DatabaseField field,
AbstractSession session)
valueFromObject in class DatabaseMappingprotected java.lang.Object valueFromRowInternalWithJoin(AbstractRecord row, JoinedAttributeManager joinManager, AbstractSession executionSession) throws DatabaseException
valueFromRowInternalWithJoin in class ForeignReferenceMappingDatabaseExceptionprotected java.lang.Object valueFromRowInternal(AbstractRecord row, JoinedAttributeManager joinManager, AbstractSession executionSession) throws DatabaseException
valueFromRowInternal in class ForeignReferenceMappingDatabaseExceptionpublic void writeFromObjectIntoRow(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
writeFromObjectIntoRow in class DatabaseMappingpublic void writeFromObjectIntoRowForShallowDelete(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
writeFromObjectIntoRowForShallowDelete in class DatabaseMappingpublic void writeFromObjectIntoRowForShallowInsert(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
writeFromObjectIntoRowForShallowInsert in class DatabaseMappingprotected void writeFromObjectIntoRowForShallowOperation(java.lang.Object object,
AbstractRecord databaseRow,
AbstractSession session)
public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord databaseRow, AbstractSession session)
writeFromObjectIntoRowWithChangeRecord in class DatabaseMappingpublic void writeFromObjectIntoRowForShallowInsertWithChangeRecord(ChangeRecord ChangeRecord, AbstractRecord databaseRow, AbstractSession session)
writeFromObjectIntoRowForShallowInsertWithChangeRecord in class DatabaseMappingpublic void writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session)
writeInsertFieldsIntoRow in class DatabaseMapping