public class DescriptorQueryManager
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Purpose: The query manager allows for the database operations that EclipseLink 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 EclipseLink will use to insert the object. Queries can be customized to extend EclipseLink 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 java.lang.String |
additionalCriteria |
protected Expression |
additionalJoinExpression |
protected org.eclipse.persistence.internal.helper.ConcurrentFixedCache |
cachedExpressionQueries
PERF: Expression query call cache for avoiding regenerated dynamic query SQL.
|
protected org.eclipse.persistence.internal.helper.ConcurrentFixedCache |
cachedUpdateCalls
PERF: Update call cache for avoiding regenerated update SQL.
|
static int |
DefaultTimeout |
protected DeleteObjectQuery |
deleteQuery |
protected ClassDescriptor |
descriptor |
protected DoesExistQuery |
doesExistQuery |
protected boolean |
hasCustomMultipleTableJoinExpression |
protected InsertObjectQuery |
insertQuery |
protected Expression |
multipleTableJoinExpression |
static int |
NoTimeout
queryTimeout has three possible settings: DefaultTimeout, NoTimeout, and 1..N
This applies to both DatabaseQuery.queryTimeout and DescriptorQueryManager.queryTimeout
DatabaseQuery.queryTimeout:
- DefaultTimeout: get queryTimeout from DescriptorQueryManager
- NoTimeout, 1..N: overrides queryTimeout in DescriptorQueryManager
DescriptorQueryManager.queryTimeout:
- DefaultTimeout: get queryTimeout from parent DescriptorQueryManager.
|
protected java.util.Map<java.lang.String,java.util.List<DatabaseQuery>> |
queries |
protected int |
queryTimeout |
protected ReadAllQuery |
readAllQuery |
protected ReadObjectQuery |
readObjectQuery |
protected java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,Expression> |
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(java.lang.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
|
java.lang.Object |
clone()
INTERNAL:
Clone the query manager
|
boolean |
containsQuery(java.lang.String queryName)
PUBLIC:
Return true if the query is defined on the session
|
void |
convertClassNamesToClasses(java.lang.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
|
java.util.Vector |
getAllQueries()
PUBLIC:
Return the pre-defined queries for the descriptor.
|
DatabaseQuery |
getCachedExpressionQuery(DatabaseQuery query)
INTERNAL:
Return the cached SQL call for the expression query.
|
java.util.Vector |
getCachedUpdateCalls(java.util.Vector updateFields)
INTERNAL:
Return the cached update SQL call based on the updated fields.
|
Call |
getDeleteCall()
ADVANCED:
Return the receiver's delete call.
|
DeleteObjectQuery |
getDeleteQuery()
ADVANCED:
Return the receiver's delete query.
|
java.lang.String |
getDeleteSQLString()
ADVANCED:
Return the receiver's delete SQL string.
|
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.
|
java.lang.String |
getDoesExistSQLString()
ADVANCED:
Return the receiver's does exist SQL string.
|
java.lang.String |
getExistenceCheck()
INTERNAL:
This method is explicitly used by the Builder only.
|
int |
getExpressionQueryCacheMaxSize()
ADVANCED:
Return the max size of the expression query cache for avoiding regenerated dynamic query SQL.
|
Call |
getInsertCall()
ADVANCED:
Return the receiver's insert call.
|
InsertObjectQuery |
getInsertQuery()
ADVANCED:
Return the receiver's insert query.
|
java.lang.String |
getInsertSQLString()
ADVANCED:
Return the receiver's insert SQL string.
|
DatabaseQuery |
getLocalQuery(java.lang.String name,
java.util.Vector arguments)
INTENAL:
Return the query from the set of pre-defined queries with the given name and argument types.
|
DatabaseQuery |
getLocalQueryByArgumentTypes(java.lang.String name,
java.util.List argumentTypes)
INTERNAL:
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.
|
java.util.Map<java.lang.String,java.util.List<DatabaseQuery>> |
getQueries()
PUBLIC:
Return the pre-defined queries for the descriptor.
|
DatabaseQuery |
getQuery(java.lang.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(java.lang.String name,
java.util.Vector arguments)
PUBLIC:
Return the query from the set of pre-defined queries with the given name and argument types.
|
protected DatabaseQuery |
getQueryFromParent(java.lang.String name,
java.util.Vector arguments)
INTERNAL:
CR#3711: Check if the class for this descriptor has a parent class.
|
int |
getQueryTimeout()
PUBLIC:
Return the number of seconds queries will wait for their Statement to execute
|
Call |
getReadAllCall()
ADVANCED:
Return the receiver's read-all call.
|
ReadAllQuery |
getReadAllQuery()
ADVANCED:
Return the receiver's read query.
|
java.lang.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.
|
java.lang.String |
getReadObjectSQLString()
ADVANCED:
Return the receiver's read SQL string.
|
java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,Expression> |
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.
|
int |
getUpdateCallCacheSize()
ADVANCED:
Return the size of the update call cache.
|
UpdateObjectQuery |
getUpdateQuery()
ADVANCED:
Return the receiver's update query.
|
java.lang.String |
getUpdateSQLString()
ADVANCED:
Return the receiver's update SQL string.
|
boolean |
hasAdditionalCriteria()
ADVANCED:
Return true if an additional criteria has been set on this query manager.
|
boolean |
hasCustomMultipleTableJoinExpression()
INTERNAL:
Return if a custom 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(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Post initialize the mappings
|
void |
initializeQueryTimeout(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Initialize the queryTimeout to:
NoTimeout: If queryTimeout is DefaultTimeout, either directly or via inheritance.
|
void |
postDelete(DeleteObjectQuery query)
INTERNAL:
Execute the post delete operation for the query
|
void |
postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Post initializations after mappings are initialized.
|
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(DeleteObjectQuery query)
INTERNAL:
Execute the pre delete operation for the query
|
void |
preInitialize(org.eclipse.persistence.internal.sessions.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 |
putCachedExpressionQuery(DatabaseQuery query)
INTERNAL:
Set the cached SQL call for the expression query.
|
void |
putCachedUpdateCalls(java.util.Vector updateFields,
java.util.Vector updateCalls)
INTERNAL:
Cache a clone of the update SQL calls based on the updated fields.
|
void |
removeCachedExpressionQuery(DatabaseQuery query)
INTERNAL:
Remove the cached expression query.
|
void |
removeQuery(java.lang.String queryName)
PUBLIC:
Remove all queries with the given query name from the set of pre-defined queries
|
void |
removeQuery(java.lang.String queryName,
java.util.Vector argumentTypes)
PUBLIC:
Remove the specific query with the given queryName and argumentTypes.
|
void |
setAdditionalCriteria(java.lang.String additionalCriteria)
ADVANCED:
Set the additional join criteria that will be used to form the additional
join expression.
|
void |
setAdditionalJoinExpression(Expression additionalJoinExpression)
ADVANCED:
Set the additional join expression.
|
void |
setAllQueries(java.util.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(java.lang.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(java.lang.String sqlString)
ADVANCED:
Set the receiver's does exist SQL string.
|
void |
setExistenceCheck(java.lang.String token)
INTERNAL:
This method is explicitly used by the Builder only.
|
void |
setExpressionQueryCacheMaxSize(int maxSize)
ADVANCED:
Set the max size of the expression query cache for avoiding regenerated dynamic query SQL.
|
protected void |
setHasCustomMultipleTableJoinExpression(boolean hasCustomMultipleTableJoinExpression)
INTENAL:
Set if a custom 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(java.lang.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 EclipseLink 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(java.util.Map map)
PUBLIC:
set the pre-defined queries for the descriptor.
|
void |
setQueryTimeout(int queryTimeout)
PUBLIC:
Set the number of seconds that queries will wait for their Statement to execute.
|
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(java.lang.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(java.lang.String sqlString)
ADVANCED:
Set the receiver's read SQL string.
|
void |
setUpdateCall(Call call)
ADVANCED:
Set the receiver's update call.
|
void |
setUpdateCallCacheSize(int updateCallCacheSize)
ADVANCED:
Set the size of the update call cache.
|
void |
setUpdateQuery(UpdateObjectQuery updateQuery)
ADVANCED:
Set the receiver's update query.
|
void |
setUpdateSQLString(java.lang.String sqlString)
ADVANCED:
Set the receiver's update SQL string.
|
protected void |
updatePropertyParameterExpression(Expression exp)
INTERNAL:
This method will walk the given expression and mark any parameter
expressions as property expressions.
|
protected InsertObjectQuery insertQuery
protected UpdateObjectQuery updateQuery
protected ReadObjectQuery readObjectQuery
protected ReadAllQuery readAllQuery
protected DeleteObjectQuery deleteQuery
protected DoesExistQuery doesExistQuery
protected ClassDescriptor descriptor
protected boolean hasCustomMultipleTableJoinExpression
protected java.lang.String additionalCriteria
protected transient Expression additionalJoinExpression
protected transient Expression multipleTableJoinExpression
protected java.util.Map<java.lang.String,java.util.List<DatabaseQuery>> queries
protected transient java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,Expression> tablesJoinExpressions
protected transient org.eclipse.persistence.internal.helper.ConcurrentFixedCache cachedUpdateCalls
protected transient org.eclipse.persistence.internal.helper.ConcurrentFixedCache cachedExpressionQueries
public static final int NoTimeout
public static final int DefaultTimeout
protected int queryTimeout
public DescriptorQueryManager()
public void setExpressionQueryCacheMaxSize(int maxSize)
public int getExpressionQueryCacheMaxSize()
public void addQuery(java.lang.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 java.lang.Object clone()
clone
in class java.lang.Object
public boolean containsQuery(java.lang.String queryName)
public void convertClassNamesToClasses(java.lang.ClassLoader classLoader)
classLoader
- public Expression getAdditionalJoinExpression()
public DeleteObjectQuery getDeleteQuery()
public java.lang.String getDeleteSQLString()
Example, "delete from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID".
public ClassDescriptor getDescriptor()
public DoesExistQuery getDoesExistQuery()
public java.lang.String getDoesExistSQLString()
Example, "select EMPLOYEE_ID from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID".
public java.lang.String getExistenceCheck()
public InsertObjectQuery getInsertQuery()
public java.lang.String getInsertSQLString()
Example, "insert into EMPLOYEE (F_NAME, L_NAME) values (#F_NAME, #L_NAME)".
public Expression getMultipleTableJoinExpression()
public java.util.Map<java.lang.String,java.util.List<DatabaseQuery>> getQueries()
getAllQueries()
public java.util.Vector getAllQueries()
getQueries()
public void setAllQueries(java.util.Vector vector)
public void setQueries(java.util.Map map)
public DatabaseQuery getQuery(java.lang.String queryName)
getQuery(String, Vector)
public DatabaseQuery getQuery(java.lang.String name, java.util.Vector arguments)
getQuery(String)
public DatabaseQuery getLocalQuery(java.lang.String name, java.util.Vector arguments)
getQuery(String)
public DatabaseQuery getLocalQueryByArgumentTypes(java.lang.String name, java.util.List argumentTypes)
getQuery(String)
protected DatabaseQuery getQueryFromParent(java.lang.String name, java.util.Vector arguments)
public ReadAllQuery getReadAllQuery()
public java.lang.String getReadAllSQLString()
Example, "select * from EMPLOYEE"
public ReadObjectQuery getReadObjectQuery()
public java.lang.String getReadObjectSQLString()
Example, "select * from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID"
public UpdateObjectQuery getUpdateQuery()
public java.lang.String getUpdateSQLString()
Example, "update EMPLOYEE set F_NAME to #F_NAME, L_NAME to #L_NAME where EMPLOYEE_ID = #EMPLOYEE_ID".
public boolean hasAdditionalCriteria()
public boolean hasCustomMultipleTableJoinExpression()
public boolean hasDeleteQuery()
public boolean hasDoesExistQuery()
public boolean hasInsertQuery()
public boolean hasReadAllQuery()
public boolean hasReadObjectQuery()
public boolean hasUpdateQuery()
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
public void initializeQueryTimeout(org.eclipse.persistence.internal.sessions.AbstractSession session)
public DescriptorQueryManager getParentDescriptorQueryManager()
public void postDelete(DeleteObjectQuery query)
public void postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
DescriptorException
protected void updatePropertyParameterExpression(Expression exp)
postInitialize
public void postInsert(WriteObjectQuery query)
public void postUpdate(WriteObjectQuery query)
public void preDelete(DeleteObjectQuery query)
public void preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
public void preInsert(WriteObjectQuery query)
public void preUpdate(WriteObjectQuery query)
public void removeQuery(java.lang.String queryName)
removeQuery(String, Vector)
public void removeQuery(java.lang.String queryName, java.util.Vector argumentTypes)
removeQuery(String)
public void setAdditionalCriteria(java.lang.String additionalCriteria)
setAdditionalJoinExpression
public void setAdditionalJoinExpression(Expression additionalJoinExpression)
public void setDeleteQuery(DeleteObjectQuery query)
public void setDeleteSQLString(java.lang.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(java.lang.String sqlString)
Example, "select EMPLOYEE_ID from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID".
public void setDoesExistCall(Call call)
public void setExistenceCheck(java.lang.String token) throws DescriptorException
DescriptorException
protected void setHasCustomMultipleTableJoinExpression(boolean hasCustomMultipleTableJoinExpression)
public void setInsertQuery(InsertObjectQuery insertQuery)
public void setInsertCall(Call call)
public void setInsertSQLString(java.lang.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 java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,Expression> getTablesJoinExpressions()
public void setInternalMultipleTableJoinExpression(Expression multipleTableJoinExpression)
public void setMultipleTableJoinExpression(Expression multipleTableJoinExpression)
public void setReadAllQuery(ReadAllQuery query)
public void setReadAllSQLString(java.lang.String sqlString)
Example, "select * from EMPLOYEE"
public void setReadAllCall(Call call)
public void setReadObjectQuery(ReadObjectQuery query)
public void setReadObjectSQLString(java.lang.String sqlString)
Example, "select * from EMPLOYEE where EMPLOYEE_ID = #EMPLOYEE_ID"
public void setReadObjectCall(Call call)
public void setUpdateQuery(UpdateObjectQuery updateQuery)
public void setUpdateSQLString(java.lang.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)
public int getQueryTimeout()
public void setQueryTimeout(int queryTimeout)
public int getUpdateCallCacheSize()
public void setUpdateCallCacheSize(int updateCallCacheSize)
public java.util.Vector getCachedUpdateCalls(java.util.Vector updateFields)
public void putCachedUpdateCalls(java.util.Vector updateFields, java.util.Vector updateCalls)
public DatabaseQuery getCachedExpressionQuery(DatabaseQuery query)
public void putCachedExpressionQuery(DatabaseQuery query)
public void removeCachedExpressionQuery(DatabaseQuery query)