Oracle Application Server TopLink API Reference
10g Release 2 (10.1.2)

B15903-01


oracle.toplink.mappings
Class OneToOneMapping

java.lang.Object
  extended byoracle.toplink.mappings.DatabaseMapping
      extended byoracle.toplink.mappings.ForeignReferenceMapping
          extended byoracle.toplink.mappings.ObjectReferenceMapping
              extended byoracle.toplink.mappings.OneToOneMapping

All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class OneToOneMapping
extends ObjectReferenceMapping

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.

Since:
TOPLink/Java 1.0
See Also:
Serialized Form

Constructor Summary
OneToOneMapping()
PUBLIC: Default constructor.

Method Summary
void addForeignKeyFieldName(java.lang.String sourceForeignKeyFieldName, java.lang.String targetPrimaryKeyFieldName)
PUBLIC: Define the 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 buildSelectionCriteria()
This method would allow customers to get the potential selection criteria for a mapping prior to initialization.
void dontUseJoining()
PUBLIC: Indicates whether the referenced object should always be joined on read queries.
java.util.Vector getForeignKeyFieldNames()
PUBLIC: Return the foreign key field names associated with the mapping.
java.util.Vector getSourceToTargetKeyFieldAssociations()
PUBLIC: Return a collection of the source to target field value associations.
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.
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)
PUBLIC: Set a collection of the source to target field associations.
void setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
PUBLIC: Define the target foreign key relationship in the 1-1 mapping.
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.

Methods inherited from class oracle.toplink.mappings.ObjectReferenceMapping
useProxyIndirection, useProxyIndirection, useProxyIndirection

Methods inherited from class oracle.toplink.mappings.ForeignReferenceMapping
dontUseBatchReading, dontUseIndirection, getReferenceClass, getRelationshipPartnerAttributeName, privateOwnedRelationship, setCustomSelectionQuery, setIndirectionPolicy, setReferenceClass, setRelationshipPartnerAttributeName, setSelectionCriteria, setSelectionSQLString, setUsesBatchReading, setUsesIndirection, shouldUseBatchReading, useBasicIndirection, useBatchReading, useContainerIndirection, useIndirection, usesIndirection

Methods inherited from class oracle.toplink.mappings.DatabaseMapping
getAttributeClassification, getAttributeName, getGetMethodName, getSetMethodName, readOnly, readWrite, setAttributeName, setGetMethodName, setIsReadOnly, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

OneToOneMapping

public OneToOneMapping()
PUBLIC: Default constructor.

Method Detail

addForeignKeyFieldName

public void addForeignKeyFieldName(java.lang.String sourceForeignKeyFieldName,
                                   java.lang.String targetPrimaryKeyFieldName)
PUBLIC: Define the foreign key relationship in the 1-1 mapping. This method is used for composite foreign key relationships, that is the source object's table has multiple foreign key fields to the target object's primary key fields. Both the source foreign key field name and the target foreign key field name must be specified. When a foreign key is specified TopLink will automatically populate the value for that field from the target object when the object is written to the database. If the foreign key is also mapped through a direct-to-field then the direct-to-field must be set read-only.

addTargetForeignKeyFieldName

public void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName,
                                         java.lang.String sourcePrimaryKeyFieldName)
PUBLIC: Define the target foreign key relationship in the 1-1 mapping. This method is used for composite target foreign key relationships, that is the target object's table has multiple foreign key fields to the source object's primary key fields. Both the target foreign key field name and the source primary key field name must be specified. The distinction between a foreign key and target foreign key is that the 1-1 mapping will not populate the target foreign key value when written (because it is in the target table). Normally 1-1's are through foreign keys but in bi-directional 1-1's the back reference will be a target foreign key. In obscure composite legacy data models a 1-1 may consist of a foreign key part and a target foreign key part, in this case both method will be called with the correct parts.

dontUseJoining

public void dontUseJoining()
PUBLIC: Indicates whether the referenced object should always be joined on read queries. Joining will join the two classes tables to read all of the data in a single query. This should only be used if it is know that the related objects are always required with the source object, or indirection is not used.

getForeignKeyFieldNames

public java.util.Vector getForeignKeyFieldNames()
PUBLIC: Return the foreign key field names associated with the mapping. These are only the source fields that are writable.

getSourceToTargetKeyFieldAssociations

public java.util.Vector getSourceToTargetKeyFieldAssociations()
PUBLIC: Return a collection of the source to target field value associations.

buildSelectionCriteria

public Expression buildSelectionCriteria()
This method would allow customers to get the potential selection criteria for a mapping prior to initialization. This would allow them to more easily create an ammendment method that would ammend the SQL for the join. CR#3922 - This method is almost the same as initializeSelectionCriteria() the difference is that getSelectionCriteria() is not called

setForeignKeyFieldName

public void setForeignKeyFieldName(java.lang.String sourceForeignKeyFieldName)
PUBLIC: Define the foreign key relationship in the 1-1 mapping. This method is used for singleton foreign key relationships only, that is the source object's table has a foreign key field to the target object's primary key field. Only the source foreign key field name is specified. When a foreign key is specified TopLink will automatically populate the value for that field from the target object when the object is written to the database. If the foreign key is also mapped through a direct-to-field then the direct-to-field must be set read-only.

setForeignKeyFieldNames

public void setForeignKeyFieldNames(java.util.Vector fieldNames)
PUBLIC: Return the foreign key field names associated with the mapping. These are only the source fields that are writable.

setShouldVerifyDelete

public 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. It checks for the previous value of the target object through joining the source and target tables. By default it is always done, but may be disabled for performance on distributed database reasons. In the unit of work the previous value is obtained from the backup-clone so it is never used.

setSourceToTargetKeyFieldAssociations

public void setSourceToTargetKeyFieldAssociations(java.util.Vector sourceToTargetKeyFieldAssociations)
PUBLIC: Set a collection of the source to target field associations.

setTargetForeignKeyFieldName

public void setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
PUBLIC: Define the target foreign key relationship in the 1-1 mapping. This method is used for singleton target foreign key relationships only, that is the target object's table has a foreign key field to the source object's primary key field. The target foreign key field name is specified. The distinction between a foreign key and target foreign key is that the 1-1 mapping will not populate the target foreign key value when written (because it is in the target table). Normally 1-1's are through foreign keys but in bi-directional 1-1's the back reference will be a target foreign key.

setUsesJoining

public void setUsesJoining(boolean usesJoining)
PUBLIC: Indicates whether the referenced object should always be joined on read queries. Joining will join the two classes tables to read all of the data in a single query. This should only be used if it is know that the related objects are always required with the source object, or indirection is not used.

shouldUseJoining

public boolean shouldUseJoining()
PUBLIC: Indicates whether the referenced object should always be joined on read queries. Joining will join the two classes tables to read all of the data in a single query. This should only be used if it is know that the related objects are always required with the source object, or indirection is not used.

shouldVerifyDelete

public boolean shouldVerifyDelete()
PUBLIC: Verify delete is used during delete and update outside of a unit of work only. It checks for the previous value of the target object through joining the source and target tables.

useJoining

public void useJoining()
PUBLIC: Indicates whether the referenced object should always be joined on read queries. Joining will join the two classes tables to read all of the data in a single query. This should only be used if it is know that the related objects are always required with the source object, or indirection is not used.

Copyright © 1998, 2005 Oracle Corporation. All Rights Reserved.