Module org.eclipse.persistence.core
Package org.eclipse.persistence.mappings
Class RelationTableMechanism
java.lang.Object
org.eclipse.persistence.mappings.RelationTableMechanism
- All Implemented Interfaces:
Serializable
,Cloneable
Purpose: Contains relation table functionality that was originally defined in ManyToManyMapping and now is shared with OneToOneMapping.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected DataModifyQuery
Query used for single row deletion.protected boolean
protected boolean
protected DataModifyQuery
Used for insertion.protected ReadQuery
protected DatabaseTable
The intermediate relation table.protected Vector
<DatabaseField> The field in the source table that corresponds to the key in the relation tableprotected Vector
<DatabaseField> The field in the intermediate table that corresponds to the key in the source tableprotected Vector
<DatabaseField> The field in the target table that corresponds to the key in the relation tableprotected Vector
<DatabaseField> The field in the intermediate table that corresponds to the key in the target table -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddRelationTableSourceRow
(Object sourceObject, AbstractSession session, AbstractRecord databaseRow, ForeignReferenceMapping mapping) INTERNAL: Add to a row source relation fields with values extracted from the source object.addRelationTableSourceRow
(AbstractRecord sourceRow, AbstractRecord databaseRow) INTERNAL: Add to a row source relation fields with values extracted from the source row.addRelationTableTargetRow
(Object targetObject, AbstractSession session, AbstractRecord databaseRow, ForeignReferenceMapping mapping) INTERNAL: Add to a row target relation fields with values extracted from the target object.void
addSourceRelationKeyField
(DatabaseField sourceRelationKeyField, DatabaseField sourcePrimaryKeyField) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table.void
addSourceRelationKeyFieldName
(String sourceRelationKeyFieldName, String sourcePrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table.void
addTargetRelationKeyField
(DatabaseField targetRelationKeyField, DatabaseField targetPrimaryKeyField) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table.void
addTargetRelationKeyFieldName
(String targetRelationKeyFieldName, String targetPrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table.protected Expression
buildBatchCriteria
(ExpressionBuilder builder, ObjectLevelReadQuery query) INTERNAL: Return the selection criteria used to IN batch fetching.buildRelationTableSourceAndTargetRow
(Object sourceObject, Object targetObject, AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Create a row that contains source relation fields with values extracted from the source object and target relation fields with values extracted from the target object.buildRelationTableSourceAndTargetRow
(AbstractRecord sourceRow, Object targetObject, AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Create a row that contains source relation fields with values extracted from the source row and target relation fields with values extracted from the target object.buildRelationTableSourceRow
(Object sourceObject, AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Create a row that contains source relation fields with values extracted from the source object.buildRelationTableSourceRow
(AbstractRecord sourceRow) INTERNAL: Create a row that contains source relation fields with values extracted from the source row.buildSelectionCriteriaAndAddFieldsToQueryInternal
(ForeignReferenceMapping mapping, Expression criteria, boolean shouldAddTargetFields, boolean shouldAddFieldsToQuery) INTERNAL: Build the selection criteria to join the source, relation, and target tables.clone()
INTERNAL: The mapping clones itself to create deep copy.protected Vector
cloneFields
(Vector fields) INTERNAL: Helper method to clone vector of fields (used in aggregate initialization cloning).protected void
collectQueryParameters
(Set<DatabaseField> cacheFields) INTERNAL: This method is used to store the FK fields that can be cached that correspond to noncacheable mappings the FK field values will be used to re-issue the query when cloning the shared cache entityprotected Object
extractBatchKeyFromRow
(AbstractRecord row, AbstractSession session) INTERNAL: Extract the foreign key value from the source row.protected Object
extractKeyFromTargetRow
(AbstractRecord row, AbstractSession session) INTERNAL: Extract the source primary key value from the relation row.protected DataModifyQuery
protected DataModifyQuery
getRelationFieldForTargetField
(DatabaseField targetField) INTERNAL: Return the relation field for the target field.INTERNAL: Return the relation table associated with the mapping.PUBLIC: Return the relation table name associated with the mapping.PUBLIC: Return the relation table qualified name associated with the mapping.PUBLIC: Return the source key field names associated with the mapping.INTERNAL: Return all the source key fields associated with the mapping.PUBLIC: Return the source relation key field names associated with the mapping.INTERNAL: Return all the source relation key fields associated with the mapping.PUBLIC: Return the target key field names associated with the mapping.INTERNAL: Return all the target keys associated with the mapping.PUBLIC: Return the target relation key field names associated with the mapping.INTERNAL: Return all the target relation key fields associated with the mapping.protected boolean
protected boolean
boolean
INTERNAL: Indicates whether the mechanism has relation table.void
initialize
(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Initializeprotected void
initializeDeleteQuery
(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Initialize delete query.protected void
initializeExtendPessimisticLockScope
(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Initialize extendPessimisticLockeScope and lockRelationTableQuery (if required).protected void
initializeInsertQuery
(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Initialize insert query.protected void
initializeLockRelationTableQuery
(AbstractSession session, ForeignReferenceMapping mapping, Expression startCriteria) INTERNAL: Initialize lockRelationTableQuery.protected void
initializeRelationTable
(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Set the table qualifier on the relation table if requiredprotected void
INTERNAL: All the source key field names are converted to DatabaseField and stored.protected void
INTERNAL: If a user does not specify the source key then the primary keys of the source table are used.protected void
INTERNAL: All the source relation key field names are converted to DatabaseField and stored.protected void
initializeTargetKeys
(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: All the target key field names are converted to DatabaseField and stored.protected void
initializeTargetKeysWithDefaults
(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: If a user does not specify the target key then the primary keys of the target table are used.protected void
INTERNAL: All the target relation key field names are converted to DatabaseField and stored.protected boolean
INTERNAL: Checks if a single source key was specified.protected boolean
INTERNAL: Checks if a single target key was specified.joinRelationTableField
(Expression expression, Expression baseExpression) INTERNAL: Adds to the passed expression a single relation table field joined to source field.void
postPrepareNestedBatchQuery
(ReadQuery batchQuery, ObjectLevelReadQuery query) INTERNAL: Add the addition join fields to the batch query.void
PUBLIC: The default delete query for mapping can be overridden by specifying the new query.void
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
(String sqlString) PUBLIC: Set the receiver's delete SQL string.protected void
setHasCustomDeleteQuery
(boolean hasCustomDeleteQuery) protected void
setHasCustomInsertQuery
(boolean bool) void
setInsertCall
(Call call) PUBLIC: Set the receiver's insert Call.protected void
setInsertQuery
(DataModifyQuery insertQuery) void
setInsertSQLString
(String sqlString) PUBLIC: Set the receiver's insert SQL string.void
setRelationTable
(DatabaseTable relationTable) PUBLIC: Set the relational table.void
setRelationTableLockingClause
(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) INTERNAL: Return relation table locking clause.void
setRelationTableName
(String tableName) PUBLIC: Set the name of the relational table.void
setSessionName
(String name) PUBLIC: Set the name of the session to execute the mapping's queries under.void
setSourceKeyFieldNames
(Vector fieldNames) PUBLIC: Set the source key field names associated with the mapping.void
setSourceKeyFields
(Vector<DatabaseField> sourceKeyFields) INTERNAL: Set the source fields.void
setSourceRelationKeyFieldName
(String sourceRelationKeyFieldName) PUBLIC: Set the source key field in the relation table.void
setSourceRelationKeyFieldNames
(Vector fieldNames) PUBLIC: Set the source relation key field names associated with the mapping.void
setSourceRelationKeyFields
(Vector<DatabaseField> sourceRelationKeyFields) INTERNAL: Set the source fields.void
setTargetKeyFieldNames
(Vector fieldNames) INTERNAL: Set the target key field names associated with the mapping.void
setTargetKeyFields
(Vector<DatabaseField> targetKeyFields) INTERNAL: Set the target fields.void
setTargetRelationKeyFieldName
(String targetRelationKeyFieldName) PUBLIC: Set the target key field in the relation table.void
setTargetRelationKeyFieldNames
(Vector fieldNames) INTERNAL: Set the target relation key field names associated with the mapping.void
setTargetRelationKeyFields
(Vector<DatabaseField> targetRelationKeyFields) INTERNAL: Set the target fields.
-
Field Details
-
relationTable
The intermediate relation table. -
sourceKeyFields
The field in the source table that corresponds to the key in the relation table -
targetKeyFields
The field in the target table that corresponds to the key in the relation table -
sourceRelationKeyFields
The field in the intermediate table that corresponds to the key in the source table -
targetRelationKeyFields
The field in the intermediate table that corresponds to the key in the target table -
deleteQuery
Query used for single row deletion. -
hasCustomDeleteQuery
protected boolean hasCustomDeleteQuery -
insertQuery
Used for insertion. -
hasCustomInsertQuery
protected boolean hasCustomInsertQuery -
lockRelationTableQuery
-
-
Constructor Details
-
RelationTableMechanism
public RelationTableMechanism()
-
-
Method Details
-
addSourceRelationKeyField
public void addSourceRelationKeyField(DatabaseField sourceRelationKeyField, DatabaseField sourcePrimaryKeyField) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table. This method is used if the keys are composite. -
addSourceRelationKeyFieldName
public void addSourceRelationKeyFieldName(String sourceRelationKeyFieldName, String sourcePrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the source table. This method is used if the keys are composite. -
addTargetRelationKeyField
public void addTargetRelationKeyField(DatabaseField targetRelationKeyField, DatabaseField targetPrimaryKeyField) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table. This method is used if the keys are composite. -
addTargetRelationKeyFieldName
public void addTargetRelationKeyFieldName(String targetRelationKeyFieldName, String targetPrimaryKeyFieldName) PUBLIC: Add the fields in the intermediate table that corresponds to the primary key in the target table. This method is used if the keys are composite. -
buildSelectionCriteriaAndAddFieldsToQueryInternal
public Expression buildSelectionCriteriaAndAddFieldsToQueryInternal(ForeignReferenceMapping mapping, Expression criteria, boolean shouldAddTargetFields, boolean shouldAddFieldsToQuery) INTERNAL: Build the selection criteria to join the source, relation, and target tables. -
collectQueryParameters
INTERNAL: This method is used to store the FK fields that can be cached that correspond to noncacheable mappings the FK field values will be used to re-issue the query when cloning the shared cache entity -
clone
INTERNAL: The mapping clones itself to create deep copy. -
cloneFields
INTERNAL: Helper method to clone vector of fields (used in aggregate initialization cloning). -
getDeleteQuery
-
setRelationTableLockingClause
public void setRelationTableLockingClause(ObjectLevelReadQuery targetQuery, ObjectBuildingQuery sourceQuery) INTERNAL: Return relation table locking clause. -
getInsertQuery
-
getRelationTable
INTERNAL: Return the relation table associated with the mapping. -
getRelationTableName
PUBLIC: Return the relation table name associated with the mapping. -
getRelationTableQualifiedName
PUBLIC: Return the relation table qualified name associated with the mapping. -
getSourceKeyFieldNames
PUBLIC: Return the source key field names associated with the mapping. These are in-order with the sourceRelationKeyFieldNames. -
buildBatchCriteria
INTERNAL: Return the selection criteria used to IN batch fetching. -
postPrepareNestedBatchQuery
INTERNAL: Add the addition join fields to the batch query. -
extractBatchKeyFromRow
INTERNAL: Extract the foreign key value from the source row. -
extractKeyFromTargetRow
INTERNAL: Extract the source primary key value from the relation row. Used for batch reading, most following same order and fields as in the mapping. -
getSourceKeyFields
INTERNAL: Return all the source key fields associated with the mapping. -
getSourceRelationKeyFieldNames
PUBLIC: Return the source relation key field names associated with the mapping. These are in-order with the sourceKeyFieldNames. -
getSourceRelationKeyFields
INTERNAL: Return all the source relation key fields associated with the mapping. -
getTargetKeyFieldNames
PUBLIC: Return the target key field names associated with the mapping. These are in-order with the targetRelationKeyFieldNames. -
getRelationFieldForTargetField
INTERNAL: Return the relation field for the target field. -
getTargetKeyFields
INTERNAL: Return all the target keys associated with the mapping. -
getTargetRelationKeyFieldNames
PUBLIC: Return the target relation key field names associated with the mapping. These are in-order with the targetKeyFieldNames. -
getTargetRelationKeyFields
INTERNAL: Return all the target relation key fields associated with the mapping. -
hasCustomDeleteQuery
protected boolean hasCustomDeleteQuery() -
hasCustomInsertQuery
protected boolean hasCustomInsertQuery() -
hasRelationTable
public boolean hasRelationTable()INTERNAL: Indicates whether the mechanism has relation table. -
initialize
public void initialize(AbstractSession session, ForeignReferenceMapping mapping) throws DescriptorException INTERNAL: Initialize- Throws:
DescriptorException
-
initializeDeleteQuery
INTERNAL: Initialize delete query. This query is used to delete a specific row from the join table in uow, given the objects on both sides of the relation. -
initializeExtendPessimisticLockScope
protected void initializeExtendPessimisticLockScope(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Initialize extendPessimisticLockeScope and lockRelationTableQuery (if required). -
initializeInsertQuery
INTERNAL: Initialize insert query. This query is used to insert the collection of objects into the relation table. -
initializeLockRelationTableQuery
protected void initializeLockRelationTableQuery(AbstractSession session, ForeignReferenceMapping mapping, Expression startCriteria) INTERNAL: Initialize lockRelationTableQuery. -
initializeRelationTable
protected void initializeRelationTable(AbstractSession session, ForeignReferenceMapping mapping) throws DescriptorException INTERNAL: Set the table qualifier on the relation table if required- Throws:
DescriptorException
-
initializeSourceKeys
INTERNAL: All the source key field names are converted to DatabaseField and stored. -
initializeSourceKeysWithDefaults
INTERNAL: If a user does not specify the source key then the primary keys of the source table are used. -
initializeSourceRelationKeys
protected void initializeSourceRelationKeys(ForeignReferenceMapping mapping) throws DescriptorException INTERNAL: All the source relation key field names are converted to DatabaseField and stored.- Throws:
DescriptorException
-
initializeTargetKeys
INTERNAL: All the target key field names are converted to DatabaseField and stored. -
initializeTargetKeysWithDefaults
protected void initializeTargetKeysWithDefaults(AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: If a user does not specify the target key then the primary keys of the target table are used. -
initializeTargetRelationKeys
INTERNAL: All the target relation key field names are converted to DatabaseField and stored. -
isSingleSourceRelationKeySpecified
protected boolean isSingleSourceRelationKeySpecified()INTERNAL: Checks if a single source key was specified. -
isSingleTargetRelationKeySpecified
protected boolean isSingleTargetRelationKeySpecified()INTERNAL: Checks if a single target key was specified. -
joinRelationTableField
INTERNAL: Adds to the passed expression a single relation table field joined to source field. Used to extend pessimistic locking clause in source query. -
setCustomDeleteQuery
PUBLIC: The default delete query for mapping can be overridden by specifying the new query. This query must delete the row from the M-M join table. -
setCustomInsertQuery
PUBLIC: The default insert query for mapping can be overridden by specifying the new query. This query must insert the row into the M-M join table. -
setDeleteQuery
-
setDeleteSQLString
PUBLIC: Set the receiver's delete SQL string. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row, through replacing the field names marked by '#' with the values for those fields. This is used to delete a single entry from the M-M join table. Example, 'delete from PROJ_EMP where PROJ_ID = #PROJ_ID AND EMP_ID = #EMP_ID'. -
setDeleteCall
PUBLIC: Set the receiver's delete Call. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row. This is used to delete a single entry from the M-M join table. Example, 'new SQLCall("delete from PROJ_EMP where PROJ_ID = #PROJ_ID AND EMP_ID = #EMP_ID")'. -
setHasCustomDeleteQuery
protected void setHasCustomDeleteQuery(boolean hasCustomDeleteQuery) -
setHasCustomInsertQuery
protected void setHasCustomInsertQuery(boolean bool) -
setInsertQuery
-
setInsertSQLString
PUBLIC: Set the receiver's insert SQL string. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row, through replacing the field names marked by '#' with the values for those fields. This is used to insert an entry into the M-M join table. Example, 'insert into PROJ_EMP (EMP_ID, PROJ_ID) values (#EMP_ID, #PROJ_ID)'. -
setInsertCall
PUBLIC: Set the receiver's insert Call. This allows the user to override the SQL generated by TOPLink, with there own SQL or procedure call. The arguments are translated from the fields of the source row. This is used to insert an entry into the M-M join table. Example, 'new SQLCall("insert into PROJ_EMP (EMP_ID, PROJ_ID) values (#EMP_ID, #PROJ_ID)")'. -
setRelationTable
PUBLIC: Set the relational table. This is the join table that store both the source and target primary keys. -
setRelationTableName
PUBLIC: Set the name of the relational table. This is the join table that store both the source and target primary keys. -
setSessionName
PUBLIC: Set the name of the session to execute the mapping's queries under. This can be used by the session broker to override the default session to be used for the target class. -
setSourceKeyFieldNames
PUBLIC: Set the source key field names associated with the mapping. These must be in-order with the sourceRelationKeyFieldNames. -
setSourceKeyFields
INTERNAL: Set the source fields. -
setSourceRelationKeyFieldName
PUBLIC: Set the source key field in the relation table. This is the name of the foreign key in the relation table to the source's primary key field. This method is used if the source primary key is a singleton only. -
setSourceRelationKeyFieldNames
PUBLIC: Set the source relation key field names associated with the mapping. These must be in-order with the sourceKeyFieldNames. -
setSourceRelationKeyFields
INTERNAL: Set the source fields. -
setTargetKeyFieldNames
INTERNAL: Set the target key field names associated with the mapping. These must be in-order with the targetRelationKeyFieldNames. -
setTargetKeyFields
INTERNAL: Set the target fields. -
setTargetRelationKeyFieldName
PUBLIC: Set the target key field in the relation table. This is the name of the foreign key in the relation table to the target's primary key field. This method is used if the target's primary key is a singleton only. -
setTargetRelationKeyFieldNames
INTERNAL: Set the target relation key field names associated with the mapping. These must be in-order with the targetKeyFieldNames. -
setTargetRelationKeyFields
INTERNAL: Set the target fields. -
buildRelationTableSourceRow
public AbstractRecord buildRelationTableSourceRow(Object sourceObject, AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Create a row that contains source relation fields with values extracted from the source object. -
addRelationTableSourceRow
public AbstractRecord addRelationTableSourceRow(Object sourceObject, AbstractSession session, AbstractRecord databaseRow, ForeignReferenceMapping mapping) INTERNAL: Add to a row source relation fields with values extracted from the source object. -
buildRelationTableSourceRow
INTERNAL: Create a row that contains source relation fields with values extracted from the source row. -
addRelationTableSourceRow
public AbstractRecord addRelationTableSourceRow(AbstractRecord sourceRow, AbstractRecord databaseRow) INTERNAL: Add to a row source relation fields with values extracted from the source row. -
addRelationTableTargetRow
public AbstractRecord addRelationTableTargetRow(Object targetObject, AbstractSession session, AbstractRecord databaseRow, ForeignReferenceMapping mapping) INTERNAL: Add to a row target relation fields with values extracted from the target object. -
buildRelationTableSourceAndTargetRow
public AbstractRecord buildRelationTableSourceAndTargetRow(Object sourceObject, Object targetObject, AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Create a row that contains source relation fields with values extracted from the source object and target relation fields with values extracted from the target object. -
buildRelationTableSourceAndTargetRow
public AbstractRecord buildRelationTableSourceAndTargetRow(AbstractRecord sourceRow, Object targetObject, AbstractSession session, ForeignReferenceMapping mapping) INTERNAL: Create a row that contains source relation fields with values extracted from the source row and target relation fields with values extracted from the target object.
-