|
EclipseLink 1.2.0, build 'v20091016-r5565' API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.persistence.mappings.DatabaseMapping org.eclipse.persistence.mappings.ForeignReferenceMapping org.eclipse.persistence.mappings.CollectionMapping org.eclipse.persistence.mappings.ManyToManyMapping
public class ManyToManyMapping
Purpose: Many to many mappings are used to represent the relationships between a collection of source objects and a collection of target objects. The mapping require the creation of an intermediate table for managing the associations between the source and target records.
Field Summary | |
---|---|
protected HistoryPolicy |
historyPolicy
|
protected RelationTableMechanism |
mechanism
Mechanism holds relationTable and all fields and queries associated with it. |
protected static java.lang.String |
ObjectAdded
|
protected static java.lang.String |
ObjectRemoved
|
protected static java.lang.String |
PostInsert
Used for data modification events. |
Fields inherited from class org.eclipse.persistence.mappings.CollectionMapping |
---|
changeOrderTargetQuery, containerPolicy, deleteAllQuery, hasCustomDeleteAllQuery, hasOrderBy, isListOrderFieldSupported, listOrderField, orderCorrectionType |
Fields inherited from class org.eclipse.persistence.mappings.ForeignReferenceMapping |
---|
cascadeMerge, cascadePersist, cascadeRefresh, cascadeRemove, forceInitializationOfSelectionCriteria, hasCustomSelectionQuery, indirectionPolicy, INNER_JOIN, isPrivateOwned, joinFetch, NONE, OUTER_JOIN, referenceClass, referenceClassName, referenceDescriptor, relationshipPartner, relationshipPartnerAttributeName, requiresTransientWeavedFields, selectionQuery, tempInitSession, usesBatchReading |
Fields inherited from class org.eclipse.persistence.mappings.DatabaseMapping |
---|
attributeAccessor, attributeName, descriptor, fields, isDerivedIdMapping, isLazy, isMapKeyMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isRemotelyInitialized, mappedByIdValue, NO_FIELDS, NO_WEIGHT, properties, weight, WEIGHT_1 |
Constructor Summary | |
---|---|
ManyToManyMapping()
PUBLIC: Default constructor. |
Method Summary | |
---|---|
void |
addSourceRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField sourceRelationKeyField,
org.eclipse.persistence.internal.helper.DatabaseField sourcePrimaryKeyField)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table. |
void |
addSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName,
java.lang.String sourcePrimaryKeyFieldName)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table. |
void |
addTargetRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField targetRelationKeyField,
org.eclipse.persistence.internal.helper.DatabaseField targetPrimaryKeyField)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table. |
void |
addTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName,
java.lang.String targetPrimaryKeyFieldName)
PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table. |
protected void |
buildListOrderField()
INTERNAL: Verifies listOrderField's table: it must be relation table. |
java.lang.Object |
clone()
INTERNAL: The mapping clones itself to create deep copy. |
java.lang.Object |
createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow,
ObjectBuildingQuery query,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL Called when a DatabaseMapping is used to map the key in a collection. |
void |
earlyPreDelete(DeleteObjectQuery query)
INTERNAL: This method is called to update collection tables prior to commit. |
void |
extendPessimisticLockScopeInSourceQuery(ObjectLevelReadQuery sourceQuery)
INTERNAL: Called only if both shouldExtendPessimisticLockScope and shouldExtendPessimisticLockScopeInSourceQuery are true. |
protected void |
extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery,
ObjectBuildingQuery sourceQuery)
INTERNAL: Adds locking clause to the target query to extend pessimistic lock scope. |
protected java.util.Vector |
extractKeyFromTargetRow(org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Extract the source primary key value from the relation row. |
protected java.util.Vector |
extractPrimaryKeyFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Extract the primary key value from the source row. |
protected DataModifyQuery |
getDeleteQuery()
|
protected ReadQuery |
getExtendPessimisticLockScopeDedicatedQuery(org.eclipse.persistence.internal.sessions.AbstractSession session,
short lockMode)
INTERNAL: Should be overridden by subclass that allows setting extendPessimisticLockScope to DEDICATED_QUERY. |
HistoryPolicy |
getHistoryPolicy()
PUBLIC: |
protected DataModifyQuery |
getInsertQuery()
|
Expression |
getJoinCriteria(org.eclipse.persistence.internal.expressions.QueryKeyExpression exp)
INTERNAL: Returns the join criteria stored in the mapping selection query. |
org.eclipse.persistence.internal.helper.DatabaseTable |
getRelationTable()
INTERNAL: Return the relation table associated with the mapping. |
RelationTableMechanism |
getRelationTableMechanism()
PUBLIC: Returns RelationTableMechanism that may be owned by the mapping. |
java.lang.String |
getRelationTableName()
PUBLIC: Return the relation table name associated with the mapping. |
java.lang.String |
getRelationTableQualifiedName()
PUBLIC: Return the relation table qualified name associated with the mapping. |
Expression |
getSelectionCriteria()
INTERNAL: Returns the selection criteria stored in the mapping selection query. |
ReadQuery |
getSelectionQuery()
INTERNAL: Returns the read query assoicated with the mapping. |
java.util.Vector |
getSourceKeyFieldNames()
PUBLIC: Return the source key field names associated with the mapping. |
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getSourceKeyFields()
INTERNAL: Return all the source key fields associated with the mapping. |
java.util.Vector |
getSourceRelationKeyFieldNames()
PUBLIC: Return the source relation key field names associated with the mapping. |
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getSourceRelationKeyFields()
INTERNAL: Return all the source relation key fields associated with the mapping. |
java.util.Vector |
getTargetKeyFieldNames()
PUBLIC: Return the target key field names associated with the mapping. |
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getTargetKeyFields()
INTERNAL: Return all the target keys associated with the mapping. |
java.util.Vector |
getTargetRelationKeyFieldNames()
PUBLIC: Return the target relation key field names associated with the mapping. |
java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> |
getTargetRelationKeyFields()
INTERNAL: Return all the target relation key fields associated with the mapping. |
protected boolean |
hasCustomDeleteQuery()
|
protected boolean |
hasCustomInsertQuery()
|
boolean |
hasDependency()
INTERNAL: The join table is a dependency if not read-only. |
void |
initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initialize mappings |
protected void |
initializeChangeOrderTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initialize changeOrderTargetQuery. |
protected void |
initializeDeleteAllQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
Initialize delete all query. |
protected void |
initializeListOrderFieldTable(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Initializes listOrderField's table. |
protected void |
initializeSelectionCriteriaAndAddFieldsToQuery(Expression startCriteria)
INTERNAL: Selection criteria is created to read target records from the table. |
protected void |
insertAddedObjectEntry(ObjectLevelModifyQuery query,
java.lang.Object objectAdded,
java.util.Map extraData)
INTERNAL: An object was added to the collection during an update, insert it. |
void |
insertIntoRelationTable(WriteObjectQuery query)
INTERNAL: Insert into relation table. |
void |
insertTargetObjects(WriteObjectQuery query)
INTERNAL: Write the target objects if the cascade policy requires them to be written first. |
boolean |
isJoiningSupported()
INTERNAL: Return if this mapping support joining. |
boolean |
isManyToManyMapping()
INTERNAL: |
boolean |
isRelationalMapping()
INTERNAL: |
protected boolean |
mustDeleteReferenceObjectsOneByOne()
For Many To Many mappings referenced objects are deleted one by one. |
protected void |
objectAddedDuringUpdate(ObjectLevelModifyQuery query,
java.lang.Object objectAdded,
org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet,
java.util.Map extraData)
INTERNAL: An object was added to the collection during an update, insert it if private. |
protected void |
objectOrderChangedDuringUpdate(WriteObjectQuery query,
java.lang.Object orderChangedObject,
int orderIndex)
|
protected void |
objectRemovedDuringUpdate(ObjectLevelModifyQuery query,
java.lang.Object objectDeleted,
java.util.Map extraData)
INTERNAL: An object was removed to the collection during an update, delete it if private. |
void |
performDataModificationEvent(java.lang.Object[] event,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Perform the commit event. |
void |
postInsert(WriteObjectQuery query)
INTERNAL: Insert into relation table. |
protected void |
postPrepareNestedBatchQuery(ReadQuery batchQuery,
ReadAllQuery query)
INTERNAL: Add additional fields and check for history. |
void |
postUpdate(WriteObjectQuery query)
INTERNAL: Update the relation table with the entries related to this mapping. |
void |
preDelete(DeleteObjectQuery query)
INTERNAL: Delete entries related to this mapping from the relation table. |
protected ReadQuery |
prepareHistoricalQuery(ReadQuery targetQuery,
ObjectBuildingQuery sourceQuery,
org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
INTERNAL: Append the temporal selection to the query selection criteria. |
protected void |
prepareTranslationRow(org.eclipse.persistence.internal.sessions.AbstractRecord translationRow,
java.lang.Object object,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: The translation row may require additional fields than the primary key if the mapping in not on the primary key. |
void |
setCustomDeleteQuery(DataModifyQuery query)
PUBLIC: The default delete query for mapping can be overridden by specifying the new query. |
void |
setCustomInsertQuery(DataModifyQuery query)
PUBLIC: The default insert query for mapping can be overridden by specifying the new query. |
void |
setDeleteCall(Call call)
PUBLIC: Set the receiver's delete Call. |
protected void |
setDeleteQuery(DataModifyQuery deleteQuery)
|
void |
setDeleteSQLString(java.lang.String sqlString)
PUBLIC: Set the receiver's delete SQL string. |
void |
setHistoryPolicy(HistoryPolicy policy)
PUBLIC: |
void |
setInsertCall(Call call)
PUBLIC: Set the receiver's insert Call. |
protected void |
setInsertQuery(DataModifyQuery insertQuery)
|
void |
setInsertSQLString(java.lang.String sqlString)
PUBLIC: Set the receiver's insert SQL string. |
void |
setRelationTable(org.eclipse.persistence.internal.helper.DatabaseTable relationTable)
PUBLIC: Set the relational table. |
void |
setRelationTableName(java.lang.String tableName)
PUBLIC: Set the name of the relational table. |
void |
setSessionName(java.lang.String name)
PUBLIC: Set the name of the session to execute the mapping's queries under. |
void |
setSourceKeyFieldNames(java.util.Vector fieldNames)
PUBLIC: Set the source key field names associated with the mapping. |
void |
setSourceKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields)
INTERNAL: Set the source fields. |
void |
setSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName)
PUBLIC: Set the source key field in the relation table. |
void |
setSourceRelationKeyFieldNames(java.util.Vector fieldNames)
PUBLIC: Set the source relation key field names associated with the mapping. |
void |
setSourceRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceRelationKeyFields)
INTERNAL: Set the source fields. |
void |
setTargetKeyFieldNames(java.util.Vector fieldNames)
INTERNAL: Set the target key field names associated with the mapping. |
void |
setTargetKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetKeyFields)
INTERNAL: Set the target fields. |
void |
setTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName)
PUBLIC: Set the target key field in the relation table. |
void |
setTargetRelationKeyFieldNames(java.util.Vector fieldNames)
INTERNAL: Set the target relation key field names associated with the mapping. |
void |
setTargetRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetRelationKeyFields)
INTERNAL: Set the target fields. |
boolean |
shouldUseListOrderFieldTableExpression()
INTERNAL: Indicates whether getListOrderFieldExpression method should create field expression on table expression. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String PostInsert
protected static final java.lang.String ObjectRemoved
protected static final java.lang.String ObjectAdded
protected transient RelationTableMechanism mechanism
protected HistoryPolicy historyPolicy
Constructor Detail |
---|
public ManyToManyMapping()
Method Detail |
---|
public boolean isRelationalMapping()
isRelationalMapping
in class DatabaseMapping
public void addSourceRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField sourceRelationKeyField, org.eclipse.persistence.internal.helper.DatabaseField sourcePrimaryKeyField)
public void addSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName, java.lang.String sourcePrimaryKeyFieldName)
public void addTargetRelationKeyField(org.eclipse.persistence.internal.helper.DatabaseField targetRelationKeyField, org.eclipse.persistence.internal.helper.DatabaseField targetPrimaryKeyField)
public void addTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName, java.lang.String targetPrimaryKeyFieldName)
public java.lang.Object clone()
clone
in class CollectionMapping
public void earlyPreDelete(DeleteObjectQuery query)
earlyPreDelete
in class DatabaseMapping
public java.lang.Object createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.sessions.AbstractSession session)
createMapComponentFromRow
in interface MapComponentMapping
protected void extendPessimisticLockScopeInTargetQuery(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery)
extendPessimisticLockScopeInTargetQuery
in class ForeignReferenceMapping
public void extendPessimisticLockScopeInSourceQuery(ObjectLevelReadQuery sourceQuery)
extendPessimisticLockScopeInSourceQuery
in class ForeignReferenceMapping
protected java.util.Vector extractKeyFromTargetRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
extractKeyFromTargetRow
in class CollectionMapping
protected java.util.Vector extractPrimaryKeyFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
extractPrimaryKeyFromRow
in class CollectionMapping
protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ReadAllQuery query)
postPrepareNestedBatchQuery
in class ForeignReferenceMapping
protected DataModifyQuery getDeleteQuery()
protected ReadQuery getExtendPessimisticLockScopeDedicatedQuery(org.eclipse.persistence.internal.sessions.AbstractSession session, short lockMode)
getExtendPessimisticLockScopeDedicatedQuery
in class ForeignReferenceMapping
protected DataModifyQuery getInsertQuery()
public Expression getJoinCriteria(org.eclipse.persistence.internal.expressions.QueryKeyExpression exp)
getJoinCriteria
in class CollectionMapping
public HistoryPolicy getHistoryPolicy()
public RelationTableMechanism getRelationTableMechanism()
public org.eclipse.persistence.internal.helper.DatabaseTable getRelationTable()
public java.lang.String getRelationTableName()
public java.lang.String getRelationTableQualifiedName()
public Expression getSelectionCriteria()
getSelectionCriteria
in class ForeignReferenceMapping
OneToOneMapping.buildSelectionCriteria()
,
OneToManyMapping.buildSelectionCriteria()
public ReadQuery getSelectionQuery()
getSelectionQuery
in class ForeignReferenceMapping
public java.util.Vector getSourceKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeyFields()
public java.util.Vector getSourceRelationKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getSourceRelationKeyFields()
public java.util.Vector getTargetKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetKeyFields()
public java.util.Vector getTargetRelationKeyFieldNames()
public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetRelationKeyFields()
protected boolean hasCustomDeleteQuery()
protected boolean hasCustomInsertQuery()
public boolean hasDependency()
hasDependency
in class DatabaseMapping
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
initialize
in class CollectionMapping
DescriptorException
protected void buildListOrderField()
buildListOrderField
in class CollectionMapping
public boolean shouldUseListOrderFieldTableExpression()
shouldUseListOrderFieldTableExpression
in class CollectionMapping
protected void initializeChangeOrderTargetQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
initializeChangeOrderTargetQuery
in class CollectionMapping
protected void initializeDeleteAllQuery(org.eclipse.persistence.internal.sessions.AbstractSession session)
protected void initializeListOrderFieldTable(org.eclipse.persistence.internal.sessions.AbstractSession session)
initializeListOrderFieldTable
in class CollectionMapping
protected void initializeSelectionCriteriaAndAddFieldsToQuery(Expression startCriteria)
protected void insertAddedObjectEntry(ObjectLevelModifyQuery query, java.lang.Object objectAdded, java.util.Map extraData) throws DatabaseException, OptimisticLockException
DatabaseException
OptimisticLockException
public void insertIntoRelationTable(WriteObjectQuery query) throws DatabaseException
- Extract primary key and its value from the source object.
- Extract target key and its value from the target object.
- Construct a insert statement with above fields and values for relation table.
- execute the statement.
- Repeat above three statements until all the target objects are done.
DatabaseException
public void insertTargetObjects(WriteObjectQuery query) throws DatabaseException, OptimisticLockException
DatabaseException
OptimisticLockException
public boolean isJoiningSupported()
isJoiningSupported
in class ForeignReferenceMapping
public boolean isManyToManyMapping()
isManyToManyMapping
in class DatabaseMapping
protected boolean mustDeleteReferenceObjectsOneByOne()
mustDeleteReferenceObjectsOneByOne
in class CollectionMapping
protected void objectAddedDuringUpdate(ObjectLevelModifyQuery query, java.lang.Object objectAdded, org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, java.util.Map extraData) throws DatabaseException, OptimisticLockException
objectAddedDuringUpdate
in class CollectionMapping
DatabaseException
OptimisticLockException
protected void objectRemovedDuringUpdate(ObjectLevelModifyQuery query, java.lang.Object objectDeleted, java.util.Map extraData) throws DatabaseException, OptimisticLockException
objectRemovedDuringUpdate
in class CollectionMapping
DatabaseException
OptimisticLockException
protected void objectOrderChangedDuringUpdate(WriteObjectQuery query, java.lang.Object orderChangedObject, int orderIndex)
objectOrderChangedDuringUpdate
in class CollectionMapping
public void performDataModificationEvent(java.lang.Object[] event, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DatabaseException, DescriptorException
performDataModificationEvent
in class DatabaseMapping
DatabaseException
DescriptorException
public void postInsert(WriteObjectQuery query) throws DatabaseException
- Extract primary key and its value from the source object.
- Extract target key and its value from the target object.
- Construct a insert statement with above fields and values for relation table.
- execute the statement.
- Repeat above three statements until all the target objects are done.
postInsert
in class CollectionMapping
DatabaseException
public void postUpdate(WriteObjectQuery query) throws DatabaseException
postUpdate
in class DatabaseMapping
DatabaseException
public void preDelete(DeleteObjectQuery query) throws DatabaseException
preDelete
in class DatabaseMapping
DatabaseException
protected void prepareTranslationRow(org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractSession session)
prepareTranslationRow
in class CollectionMapping
public void setCustomDeleteQuery(DataModifyQuery query)
public void setCustomInsertQuery(DataModifyQuery query)
protected void setDeleteQuery(DataModifyQuery deleteQuery)
public void setDeleteSQLString(java.lang.String sqlString)
public void setDeleteCall(Call call)
protected void setInsertQuery(DataModifyQuery insertQuery)
public void setInsertSQLString(java.lang.String sqlString)
public void setInsertCall(Call call)
public void setRelationTable(org.eclipse.persistence.internal.helper.DatabaseTable relationTable)
public void setHistoryPolicy(HistoryPolicy policy)
public void setRelationTableName(java.lang.String tableName)
public void setSessionName(java.lang.String name)
setSessionName
in class CollectionMapping
public void setSourceKeyFieldNames(java.util.Vector fieldNames)
public void setSourceKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields)
public void setSourceRelationKeyFieldName(java.lang.String sourceRelationKeyFieldName)
public void setSourceRelationKeyFieldNames(java.util.Vector fieldNames)
public void setSourceRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceRelationKeyFields)
public void setTargetKeyFieldNames(java.util.Vector fieldNames)
public void setTargetKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetKeyFields)
public void setTargetRelationKeyFieldName(java.lang.String targetRelationKeyFieldName)
public void setTargetRelationKeyFieldNames(java.util.Vector fieldNames)
public void setTargetRelationKeyFields(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetRelationKeyFields)
protected ReadQuery prepareHistoricalQuery(ReadQuery targetQuery, ObjectBuildingQuery sourceQuery, org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
prepareHistoricalQuery
in class ForeignReferenceMapping
|
EclipseLink 1.2.0, build 'v20091016-r5565' API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |