public class DescriptorQueryManager extends Object implements Cloneable, Serializable
Purpose: The query manager allows for the database opperations that TopLink performs to be customized by the application. For each descriptor a query can be given that controls how a operation will occur. A common example is if the application requires a stored procedure to be used to insert the object, it can override the SQL call in the insert query that TopLink will use to insert the object. Queries can be customized to extend TopLink behavior, access non-relational data or use stored procedures or customized SQL calls.
The queries that can be customized include:
ClassDescriptor
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected Expression |
additionalJoinExpression |
protected DeleteObjectQuery |
deleteQuery |
protected ClassDescriptor |
descriptor |
protected DoesExistQuery |
doesExistQuery |
protected boolean |
hasCustomMultipleTableJoinExpression |
protected InsertObjectQuery |
insertQuery |
protected Expression |
multipleTableJoinExpression |
protected Map |
queries |
protected ReadAllQuery |
readAllQuery |
protected ReadObjectQuery |
readObjectQuery |
protected Map |
tablesJoinExpressions |
protected UpdateObjectQuery |
updateQuery |
Constructor and Description |
---|
DescriptorQueryManager()
INTERNAL:
Initialize the state of the descriptor query manager
|
Modifier and Type | Method and Description |
---|---|
void |
addQuery(DatabaseQuery query)
PUBLIC:
Add the query to the session queries
|
void |
addQuery(String name,
DatabaseQuery query)
PUBLIC:
Add the query to the descriptor queries with the given name
|
void |
assumeExistenceForDoesExist()
PUBLIC:
Assume that if the objects primary key does not include null then it must exist.
|
void |
assumeNonExistenceForDoesExist()
PUBLIC:
Assume that the object does not exist.
|
void |
checkCacheForDoesExist()
PUBLIC:
Default behavior.
|
void |
checkDatabaseForDoesExist()
PUBLIC:
Perform does exist check on the database
|
Object |
clone()
INTERNAL:
Clone the query manager
|
boolean |
containsQuery(String queryName)
PUBLIC:
Return true if the query is defined on the session
|
void |
convertClassNamesToClasses(ClassLoader classLoader)
INTERNAL:
Convert all the class-name-based settings in this Query Manager to actual class-based
settings
This method is implemented by subclasses as necessary.
|
Expression |
getAdditionalJoinExpression()
ADVANCED:
Returns the join expression that should be appended to all of the descriptors expressions
Contains any multiple table or inheritance dependencies
|
Vector |
getAllQueries()
PUBLIC:
Return the pre-defined queries for the descriptor.
|
Call |
getDeleteCall()
ADVANCED:
Return the receiver's delete call.
|
DeleteObjectQuery |
getDeleteQuery()
ADVANCED:
Return the receiver's delete query.
|
String |
getDeleteSQLString()
ADVANCED:
Return the receiver's delete SQL string.
|
protected ClassDescriptor |
getDescriptor()
INTERNAL:
Return the descriptor associated with this descriptor query manager
|
Call |
getDoesExistCall()
ADVANCED:
Return the receiver's does-exist call.
|
DoesExistQuery |
getDoesExistQuery()
ADVANCED:
Return the receiver's does exist query.
|
String |
getDoesExistSQLString()
ADVANCED:
Return the receiver's does exist SQL string.
|
String |
getExistenceCheck()
INTERNAL:
This method is explicitly used by the Builder only.
|
Call |
getInsertCall()
ADVANCED:
Return the receiver's insert call.
|
InsertObjectQuery |
getInsertQuery()
ADVANCED:
Return the receiver's insert query.
|
String |
getInsertSQLString()
ADVANCED:
Return the receiver's insert SQL string.
|
DatabaseQuery |
getLocalQuery(String name,
Vector arguments)
INTENAL:
Return the query from the set of pre-defined queries with the given name and argument types.
|
Expression |
getMultipleTableJoinExpression()
ADVANCED:
This is normally generated for descriptors that have multiple tables.
|
DescriptorQueryManager |
getParentDescriptorQueryManager()
INTERNAL:
Get the parent DescriptorQueryManager.
|
Map |
getQueries()
PUBLIC:
Return the pre-defined queries for the descriptor.
|
DatabaseQuery |
getQuery(String queryName)
PUBLIC:
Return the query name from the set of pre-defined queries
If only one query exists with this name, it will be returned.
|
DatabaseQuery |
getQuery(String name,
Vector arguments)
PUBLIC:
Return the query from the set of pre-defined queries with the given name and argument types.
|
protected DatabaseQuery |
getQueryFromParent(String name,
Vector arguments)
INTERNAL:
CR#3711: Check if the class for this descriptor has a parent class.
|
Call |
getReadAllCall()
ADVANCED:
Return the receiver's read-all call.
|
ReadAllQuery |
getReadAllQuery()
ADVANCED:
Return the receiver's read query.
|
String |
getReadAllSQLString()
ADVANCED:
Return the receiver's read SQL string.
|
Call |
getReadObjectCall()
ADVANCED:
Return the receiver's read-object call.
|
ReadObjectQuery |
getReadObjectQuery()
ADVANCED:
Return the receiver's read query.
|
String |
getReadObjectSQLString()
ADVANCED:
Return the receiver's read SQL string.
|
Map |
getTablesJoinExpressions()
INTERNAL:
Used in case descriptor has additional tables:
each additional table mapped to an expression joining it.
|
Call |
getUpdateCall()
ADVANCED:
Return the receiver's update call.
|
UpdateObjectQuery |
getUpdateQuery()
ADVANCED:
Return the receiver's update query.
|
String |
getUpdateSQLString()
ADVANCED:
Return the receiver's update SQL string.
|
boolean |
hasCustomMultipleTableJoinExpression()
INTERNAL:
Return if a cutsom join expression is used.
|
boolean |
hasDeleteQuery()
INTERNAL:
Flag that specifies if a delete query is available
|
boolean |
hasDoesExistQuery()
INTERNAL:
Flag that specifies if a does exist query is available
|
boolean |
hasInsertQuery()
INTERNAL:
Flag that specifies if a insert query is available
|
boolean |
hasReadAllQuery()
INTERNAL:
Flag that specifies if a read all query is available
|
boolean |
hasReadObjectQuery()
INTERNAL:
Flag that specifies if a read object query is available
|
boolean |
hasUpdateQuery()
INTERNAL:
Flag that specifies if a update query is available
|
void |
initialize(AbstractSession session)
INTERNAL:
Post initialize the mappings
|
void |
postDelete(WriteObjectQuery query)
INTERNAL:
Execute the post delete operation for the query
|
void |
postInsert(WriteObjectQuery query)
INTERNAL:
Execute the post insert operation for the query
|
void |
postUpdate(WriteObjectQuery query)
INTERNAL:
Execute the post update operation for the query
|
void |
preDelete(WriteObjectQuery query)
INTERNAL:
Execute the pre delete operation for the query
|
void |
preInitialize(AbstractSession session)
INTERNAL:
Initialize the query manager.
|
void |
preInsert(WriteObjectQuery query)
INTERNAL:
Execute the pre insert operation for the query.
|
void |
preUpdate(WriteObjectQuery query)
INTERNAL:
Execute the pre update operation for the query
|
void |
removeQuery(String queryName)
PUBLIC:
Remove all queries with the given query name from the set of pre-defined queries
|
void |
removeQuery(String queryName,
Vector argumentTypes)
PUBLIC:
Remove the specific query with the given queryName and argumentTypes.
|
void |
setAdditionalJoinExpression(Expression additionalJoinExpression)
ADVANCED:
Set the additional join expression.
|
void |
setAllQueries(Vector vector)
INTERNAL:
Set pre-defined queries for the descriptor.
|
void |
setDeleteCall(Call call)
ADVANCED:
Set the receiver's delete call.
|
void |
setDeleteQuery(DeleteObjectQuery query)
ADVANCED:
Set the receiver's delete query.
|
void |
setDeleteSQLString(String sqlString)
ADVANCED:
Set the receiver's delete SQL string.
|
void |
setDescriptor(ClassDescriptor descriptor)
INTERNAL:
Set the descriptor.
|
void |
setDoesExistCall(Call call)
ADVANCED:
Set the receiver's does exist call.
|
void |
setDoesExistQuery(DoesExistQuery query)
ADVANCED:
Set the receiver's does exist query.
|
void |
setDoesExistSQLString(String sqlString)
ADVANCED:
Set the receiver's does exist SQL string.
|
void |
setExistenceCheck(String token)
INTERNAL:
This method is explicitly used by the Builder only.
|
protected void |
setHasCustomMultipleTableJoinExpression(boolean hasCustomMultipleTableJoinExpression)
INTENAL:
Set if a cutsom join expression is used.
|
void |
setInsertCall(Call call)
ADVANCED:
Set the receiver's insert call.
|
void |
setInsertQuery(InsertObjectQuery insertQuery)
ADVANCED:
Set the receiver's insert query.
|
void |
setInsertSQLString(String sqlString)
ADVANCED:
Set the receiver's insert SQL string.
|
void |
setInternalMultipleTableJoinExpression(Expression multipleTableJoinExpression)
INTERNAL:
Used to set the multiple table join expression that was generated by TopLink as opposed
to a custom one supplied by the user.
|
void |
setMultipleTableJoinExpression(Expression multipleTableJoinExpression)
ADVANCED:
This is normally generated for descriptors that have multiple tables.
|
void |
setQueries(Map hashtable)
PUBLIC:
set the pre-defined queries for the descriptor.
|
void |
setReadAllCall(Call call)
ADVANCED:
Set the receiver's read all call.
|
void |
setReadAllQuery(ReadAllQuery query)
ADVANCED:
Set the receiver's read all query.
|
void |
setReadAllSQLString(String sqlString)
ADVANCED:
Set the receiver's read SQL string.
|
void |
setReadObjectCall(Call call)
ADVANCED:
Set the receiver's read object call.
|
void |
setReadObjectQuery(ReadObjectQuery query)
ADVANCED:
Set the receiver's read query.
|
void |
setReadObjectSQLString(String sqlString)
ADVANCED:
Set the receiver's read SQL string.
|
void |
setUpdateCall(Call call)
ADVANCED:
Set the receiver's update call.
|
void |
setUpdateQuery(UpdateObjectQuery updateQuery)
ADVANCED:
Set the receiver's update query.
|
void |
setUpdateSQLString(String sqlString)
ADVANCED:
Set the receiver's update SQL string.
|
protected transient InsertObjectQuery insertQuery
protected transient UpdateObjectQuery updateQuery
protected transient ReadObjectQuery readObjectQuery
protected transient ReadAllQuery readAllQuery
protected transient DeleteObjectQuery deleteQuery
protected DoesExistQuery doesExistQuery
protected ClassDescriptor descriptor
protected boolean hasCustomMultipleTableJoinExpression
protected transient Expression additionalJoinExpression
protected transient Expression multipleTableJoinExpression
protected transient Map queries
protected transient Map tablesJoinExpressions
public DescriptorQueryManager()
public void addQuery(String name, DatabaseQuery query)
name
- This is the name of the query. It will be set on the query and used to look it up.query
- This is the query that will be added. If the query being added has parameters, the
existing list of queries will be checked for matching queries. If a matching query exists,
it will be replaced.public void addQuery(DatabaseQuery query)
query
- DatabaseQuery This is the query that will be added. If the query being added has parameters, the
existing list of queries will be checked for matching queries. If a matching query exists,
it will be replaced.public void assumeExistenceForDoesExist()
public void assumeNonExistenceForDoesExist()
public void checkCacheForDoesExist()
public void checkDatabaseForDoesExist()
public boolean containsQuery(String queryName)
public void convertClassNamesToClasses(ClassLoader classLoader)
classLoader
- public Expression getAdditionalJoinExpression()
public DeleteObjectQuery getDeleteQuery()
public String getDeleteSQLString()
Example, "delete from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID".
protected ClassDescriptor getDescriptor()
public DoesExistQuery getDoesExistQuery()
public String getDoesExistSQLString()
Example, "select EMPLOYEE_ID from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID".
public String getExistenceCheck()
public InsertObjectQuery getInsertQuery()
public String getInsertSQLString()
Example, "insert into EMPLOYEE (F_NAME, L_NAME) values (#F_NAME, #L_NAME)".
public Expression getMultipleTableJoinExpression()
public Map getQueries()
getAllQueries()
public Vector getAllQueries()
getQueries()
public void setAllQueries(Vector vector)
public void setQueries(Map hashtable)
public DatabaseQuery getQuery(String queryName)
getQuery(String, Vector)
public DatabaseQuery getQuery(String name, Vector arguments)
getQuery(String)
public DatabaseQuery getLocalQuery(String name, Vector arguments)
getQuery(String)
protected DatabaseQuery getQueryFromParent(String name, Vector arguments)
public ReadAllQuery getReadAllQuery()
public String getReadAllSQLString()
Example, "select * from EMPLOYEE"
public ReadObjectQuery getReadObjectQuery()
public String getReadObjectSQLString()
Example, "select * from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID"
public UpdateObjectQuery getUpdateQuery()
public String getUpdateSQLString()
Example, "update EMPLOYEE set F_NAME to #F_NAME, L_NAME to #L_NAME where EMPLOYEE_ID = #EMPLOYEE_ID".
public boolean hasCustomMultipleTableJoinExpression()
public boolean hasDeleteQuery()
public boolean hasDoesExistQuery()
public boolean hasInsertQuery()
public boolean hasReadAllQuery()
public boolean hasReadObjectQuery()
public boolean hasUpdateQuery()
public void initialize(AbstractSession session)
public DescriptorQueryManager getParentDescriptorQueryManager()
public void postDelete(WriteObjectQuery query)
public void postInsert(WriteObjectQuery query)
public void postUpdate(WriteObjectQuery query)
public void preDelete(WriteObjectQuery query)
public void preInitialize(AbstractSession session)
public void preInsert(WriteObjectQuery query)
public void preUpdate(WriteObjectQuery query)
public void removeQuery(String queryName)
removeQuery(String, Vector)
public void removeQuery(String queryName, Vector argumentTypes)
removeQuery(String)
public void setAdditionalJoinExpression(Expression additionalJoinExpression)
public void setDeleteQuery(DeleteObjectQuery query)
public void setDeleteSQLString(String sqlString)
Example, "delete from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID".
public void setDeleteCall(Call call)
public void setDescriptor(ClassDescriptor descriptor)
public void setDoesExistQuery(DoesExistQuery query)
public void setDoesExistSQLString(String sqlString)
Example, "select EMPLOYEE_ID from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID".
public void setDoesExistCall(Call call)
public void setExistenceCheck(String token) throws DescriptorException
DescriptorException
protected void setHasCustomMultipleTableJoinExpression(boolean hasCustomMultipleTableJoinExpression)
public void setInsertQuery(InsertObjectQuery insertQuery)
public void setInsertCall(Call call)
public void setInsertSQLString(String sqlString)
Example, "insert into EMPLOYEE (F_NAME, L_NAME) values (#F_NAME, #L_NAME)".
public Call getInsertCall()
public Call getUpdateCall()
public Call getDeleteCall()
public Call getReadObjectCall()
public Call getReadAllCall()
public Call getDoesExistCall()
public Map getTablesJoinExpressions()
public void setInternalMultipleTableJoinExpression(Expression multipleTableJoinExpression)
public void setMultipleTableJoinExpression(Expression multipleTableJoinExpression)
public void setReadAllQuery(ReadAllQuery query)
public void setReadAllSQLString(String sqlString)
Example, "select * from EMPLOYEE"
public void setReadAllCall(Call call)
public void setReadObjectQuery(ReadObjectQuery query)
public void setReadObjectSQLString(String sqlString)
Example, "select * from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID"
public void setReadObjectCall(Call call)
public void setUpdateQuery(UpdateObjectQuery updateQuery)
public void setUpdateSQLString(String sqlString)
Example, "update EMPLOYEE set F_NAME to #F_NAME, L_NAME to #L_NAME where EMPLOYEE_ID = #EMPLOYEE_ID".
public void setUpdateCall(Call call)
Copyright © 2021. All rights reserved.