oracle.toplink.mappings
Class OneToManyMapping
java.lang.Object
oracle.toplink.mappings.DatabaseMapping
oracle.toplink.mappings.ForeignReferenceMapping
oracle.toplink.mappings.CollectionMapping
oracle.toplink.mappings.OneToManyMapping
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ContainerMapping, oracle.toplink.mappings.RelationalMapping
public class OneToManyMapping
- extends CollectionMapping
- implements oracle.toplink.mappings.RelationalMapping
Purpose: This mapping is used to represent the
typical RDBMS relationship between a single
source object and collection of target objects; where,
on the database, the target objects have references
(foreign keys) to the source object.
- Since:
- TOPLink/Java 1.0
- See Also:
- Serialized Form
Method Summary |
void |
addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName,
java.lang.String sourceKeyFieldName)
Define the target foreign key relationship in the one-to-many mapping. |
Expression |
buildSelectionCriteria()
This method would allow customers to get the potential selection criteria for a mapping
prior to initialization. |
java.util.Vector |
getSourceKeyFieldNames()
Return the source key field names associated with the mapping. |
void |
prepareCascadeLockingPolicy()
Prepare a cascade locking policy. |
void |
setDeleteAllSQLString(java.lang.String sqlString)
Set the SQL string used by the mapping to delete the target objects. |
void |
setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
Define the target foreign key relationship in the one-to-many mapping. |
void |
setTargetForeignKeyFieldNames(java.lang.String[] targetForeignKeyFieldNames,
java.lang.String[] sourceKeyFieldNames)
Define the target foreign key relationship in the one-to-many mapping. |
Methods inherited from class oracle.toplink.mappings.CollectionMapping |
addAggregateOrderBy, addAscendingOrdering, addDescendingOrdering, addOrderBy, getRealCollectionAttributeValueFromObject, setContainerPolicy, setCustomDeleteAllQuery, setDeleteAllCall, setSessionName, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, useCollectionClass, useMapClass, useMapClass, useSortedSetClass, useTransparentCollection, useTransparentList, useTransparentMap, useTransparentSet |
Methods inherited from class oracle.toplink.mappings.ForeignReferenceMapping |
dontUseBatchReading, dontUseIndirection, getJoinFetch, getReferenceClass, getRelationshipPartnerAttributeName, isCascadeMerge, isCascadePersist, isCascadeRefresh, isCascadeRemove, isInnerJoinFetched, isJoinFetched, isOuterJoinFetched, isPrivateOwned, privateOwnedRelationship, setCascadeAll, setCascadeMerge, setCascadePersist, setCascadeRefresh, setCascadeRemove, setCustomSelectionQuery, setIndirectionPolicy, setIsPrivateOwned, setJoinFetch, setReferenceClass, setRelationshipPartnerAttributeName, setSelectionCall, setSelectionCriteria, setSelectionSQLString, setUsesBatchReading, setUsesIndirection, shouldUseBatchReading, useBasicIndirection, useBatchReading, useContainerIndirection, useInnerJoinFetch, useOuterJoinFetch, usesIndirection |
Methods inherited from class oracle.toplink.mappings.DatabaseMapping |
getAttributeAccessor, getAttributeClassification, getAttributeName, getGetMethodName, getProperty, getSetMethodName, isLazy, isOptional, isUsingMethodAccess, readOnly, readWrite, setAttributeAccessor, setAttributeName, setGetMethodName, setIsLazy, setIsOptional, setIsReadOnly, setProperty, setSetMethodName, setWeight |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
OneToManyMapping
public OneToManyMapping()
- Default constructor.
addTargetForeignKeyFieldName
public void addTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName,
java.lang.String sourceKeyFieldName)
- Define the target foreign key relationship in the one-to-many mapping.
This method is used for composite target foreign key relationships.
That is, the target object's table has multiple foreign key fields
that are references to
the source object's (typically primary) key fields.
Both the target foreign key field name and the corresponding
source primary key field name must be specified.
Because the target object's table must store a foreign key to the source table,
the target object must map that foreign key, this is normally done through a
one-to-one mapping back-reference. Other options include:
- use a DirectToFieldMapping and maintain the
foreign key fields directly in the target
- use a ManyToManyMapping
- use an AggregateCollectionMapping
- See Also:
DirectToFieldMapping
,
ManyToManyMapping
,
AggregateCollectionMapping
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 buildDefaultSelectionCriteria() the difference
is that TargetForeignKeysToSourceKeys contains more information after login then SourceKeyFields
contains before login.
getSourceKeyFieldNames
public java.util.Vector getSourceKeyFieldNames()
- Return the source key field names associated with the mapping.
These are in-order with the targetForeignKeyFieldNames.
prepareCascadeLockingPolicy
public void prepareCascadeLockingPolicy()
- Prepare a cascade locking policy.
- Overrides:
prepareCascadeLockingPolicy
in class DatabaseMapping
setDeleteAllSQLString
public void setDeleteAllSQLString(java.lang.String sqlString)
- Set the SQL string used by the mapping to delete the target objects.
This allows the developer to override the SQL
generated by TopLink with a custom SQL statement or procedure call.
The arguments are
translated from the fields of the source row, by replacing the field names
marked by '#' with the values for those fields at execution time.
A one-to-many mapping will only use this delete all optimization if the target objects
can be deleted in a single SQL call. This is possible when the target objects
are in a single table, do not using locking, do not contain other privately-owned
parts, do not read subclasses, etc.
Example: "delete from PHONE where OWNER_ID = #EMPLOYEE_ID"
- Overrides:
setDeleteAllSQLString
in class CollectionMapping
setTargetForeignKeyFieldName
public void setTargetForeignKeyFieldName(java.lang.String targetForeignKeyFieldName)
- Define the target foreign key relationship in the one-to-many mapping.
This method can be used when the foreign and primary keys
have only a single field each.
(Use #addTargetForeignKeyFieldName(String, String)
for "composite" keys.)
Only the target foreign key field name is specified and the source
(primary) key field is
assumed to be the primary key of the source object.
Because the target object's table must store a foreign key to the source table,
the target object must map that foreign key, this is normally done through a
one-to-one mapping back-reference. Other options include:
- use a DirectToFieldMapping and maintain the
foreign key fields directly in the target
- use a ManyToManyMapping
- use an AggregateCollectionMapping
- See Also:
DirectToFieldMapping
,
ManyToManyMapping
,
AggregateCollectionMapping
setTargetForeignKeyFieldNames
public void setTargetForeignKeyFieldNames(java.lang.String[] targetForeignKeyFieldNames,
java.lang.String[] sourceKeyFieldNames)
- Define the target foreign key relationship in the one-to-many 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 (typically primary) key fields.
Both the target foreign key field names and the corresponding source primary
key field names must be specified.