public class ExpressionQueryMechanism extends StatementQueryMechanism
Purpose: Mechanism used for all expression read queries. ExpressionQueryInterface understands how to deal with expressions.
Responsibilities: Translates the expression and creates the appropriate SQL statements. Retrieves the data from the database and return the results to the query.
Modifier and Type | Field and Description |
---|---|
protected Expression |
selectionCriteria |
sqlStatement, sqlStatements
call, calls
query
Constructor and Description |
---|
ExpressionQueryMechanism(DatabaseQuery query)
Initialize the state of the query
|
ExpressionQueryMechanism(DatabaseQuery query,
Expression expression)
Initialize the state of the query
|
Modifier and Type | Method and Description |
---|---|
protected Vector |
aliasFields(ObjectExpression node,
Vector fields)
Alias the supplied fields with respect to the expression node.
|
Vector |
aliasPresetFields(SQLSelectStatement statement)
If the fields in the statement have breen pre-set, e.g.
|
Expression |
buildBaseSelectionCriteria(boolean isSubSelect,
Dictionary clonedExpressions)
Create the appropriate where clause.
|
SQLSelectStatement |
buildBaseSelectStatement(boolean isSubSelect,
Dictionary clonedExpressions)
Return the appropriate select statement containing the fields in the table.
|
protected SQLSelectStatement |
buildConcreteSelectStatement()
Return the appropriate select statement containing the fields in the table.
|
protected SQLDeleteStatement |
buildDeleteAllStatement(DatabaseTable table,
Expression inheritanceExpression,
SQLCall selectCallForExist,
SQLSelectStatement selectStatementForExist,
SQLCall selectCallForNotExist,
SQLSelectStatement selectStatementForNotExist,
Collection primaryKeyFields)
Return the appropriate delete statement
Passing of a call/ statement pair is used because the same pair
may be used several times.
|
protected SQLDeleteStatement |
buildDeleteAllStatementForMapping(SQLCall selectCallForExist,
SQLSelectStatement selectStatementForExist,
Vector sourceFields,
Vector targetFields) |
protected Vector |
buildDeleteAllStatementsForMappings(SQLCall selectCallForExist,
SQLSelectStatement selectStatementForExist,
boolean dontCheckDescriptor)
Create SQLDeleteAllStatements for mappings that may be responsible for references
to the objects to be deleted
in the tables NOT mapped to any class: ManyToManyMapping and DirectCollectionMapping
NOTE: A similar pattern also used in method buildDeleteAllStatementsForMappingsWithTempTable():
if you are updating this method consider applying a similar update to that method as well.
|
protected Vector |
buildDeleteAllStatementsForMappingsWithTempTable(ClassDescriptor descriptor,
DatabaseTable rootTable,
Collection rootTablePrimaryKeyFields,
boolean dontCheckDescriptor)
Build delete statements with temporary table for ManyToMany and DirectCollection mappings.
|
protected SQLDeleteStatement |
buildDeleteStatement(DatabaseTable table)
Return the appropriate delete statement
|
protected SQLDeleteStatement |
buildDeleteStatementForDeleteAllQuery(DatabaseTable table)
Used by DeleteAllQuery to create DeleteStatement in a simple case
when selectionCriteria==null.
|
protected SQLDeleteStatement |
buildDeleteStatementForDeleteAllQuery(DatabaseTable table,
Expression inheritanceExpression)
Used by DeleteAllQuery to create DeleteStatement in a simple case
when selectionCriteria==null.
|
protected SQLInsertStatement |
buildInsertStatement(DatabaseTable table)
Return the appropriate insert statement
|
protected SQLSelectStatement |
buildNormalSelectStatement()
Return the appropriate select statement containing the fields in the table.
|
protected SQLSelectStatement |
buildReportQuerySelectStatement(boolean isSubSelect)
Return the appropriate select statement containing the fields in the table.
|
protected SQLSelectStatement |
buildReportQuerySelectStatement(boolean isSubSelect,
boolean useCustomaryInheritanceExpression,
Expression inheritanceExpression)
Customary inheritance expression is required for DeleteAllQuery and UpdateAllQuery preparation.
|
protected SQLSelectStatement |
buildSelectStatementForDoesExist(DatabaseField field)
Return the appropriate select statement to perform a does exist check
|
protected Vector |
buildStatementsForDeleteAllForTempTables()
Build SQLStatements for delete all using temporary table.
|
protected Vector |
buildStatementsForUpdateAllForTempTables(DatabaseTable table,
HashMap databaseFieldsToValues,
Collection primaryKeyFields) |
protected SQLUpdateAllStatement |
buildUpdateAllStatement(DatabaseTable table,
HashMap databaseFieldsToValues,
SQLCall selectCallForExist,
SQLSelectStatement selectStatementForExist,
Collection primaryKeyFields) |
protected SQLModifyStatement |
buildUpdateAllStatementForOracleAnonymousBlock(HashMap tables_databaseFieldsToValues,
HashMap tablesToPrimaryKeyFields) |
protected SQLUpdateStatement |
buildUpdateStatement(DatabaseTable table)
Return the appropriate update statement
|
Object |
checkCacheForObject(AbstractRecord translationRow,
AbstractSession session)
Perform a cache lookup for the query
This is only called from read object query.
|
DatabaseQueryMechanism |
clone(DatabaseQuery queryClone)
Clone the mechanism for the specified query clone.
|
protected int |
computeAndSetItemOffset(ReportItem item,
int itemOffset)
calculate indexes for an item, given the current Offset
|
protected SQLSelectStatement |
createSQLSelectStatementForAssignedExpressionForUpdateAll(Expression value) |
protected SQLSelectStatement |
createSQLSelectStatementForModifyAll(Expression whereClause) |
protected SQLSelectStatement |
createSQLSelectStatementForModifyAll(Expression whereClause,
Expression inheritanceExpression) |
protected SQLSelectStatement |
createSQLSelectStatementForModifyAll(Expression whereClause,
Expression inheritanceExpression,
ClassDescriptor desc) |
protected SQLSelectStatement |
createSQLSelectStatementForModifyAll(Expression whereClause,
Expression inheritanceExpression,
ClassDescriptor desc,
boolean useCustomaryInheritanceExpression) |
protected SQLSelectStatement |
createSQLSelectStatementForModifyAllForTempTable(HashMap databaseFieldsToValues) |
protected SQLSelectStatement |
createSQLSelectStatementForUpdateAllForOracleAnonymousBlock(HashMap tables_databaseFieldsToValues) |
void |
extractStatementFromItem(ReportItem item,
IdentityHashtable clonedExpressions,
SQLSelectStatement selectStatement,
Vector fieldExpressions) |
protected static String |
getAliasTableName(SQLSelectStatement selectStatement,
DatabaseTable table) |
ExpressionBuilder |
getExpressionBuilder()
Return an expression builder which is valid for us
|
protected ClassDescriptor |
getHighestDescriptorMappingTable(DatabaseTable table)
Pass to this method a table mapped by query's descriptor.
|
Vector |
getNonSelectionFields()
Return the fields required in the from and where clause (join).
|
protected Collection |
getPrimaryKeyFieldsForTable(ClassDescriptor descriptor,
DatabaseTable table) |
protected Collection |
getPrimaryKeyFieldsForTable(DatabaseTable table) |
Expression |
getSelectionCriteria()
Return the selection criteria of the query.
|
Vector |
getSelectionFields(SQLSelectStatement statement,
boolean includeAllSubclassFields)
Return the fields required in the select clause.
|
boolean |
isExpressionQueryMechanism()
Return true if this is an expression query mechanism.
|
boolean |
isStatementQueryMechanism()
Return true if this is a statement query mechanism
|
void |
prepare()
Override super to do nothing.
|
void |
prepareCursorSelectAllRows()
Pre-build the SQL statement from the expression.
|
void |
prepareDeleteAll()
Pre-build the SQL statement from the expression.
|
protected void |
prepareDeleteAll(Vector tablesToIgnore)
Pre-build the SQL statement from the expression.
|
protected void |
prepareDeleteAllUsingTempStorage() |
protected void |
prepareDeleteAllUsingTempTables() |
void |
prepareDeleteObject()
Pre-build the SQL statement from the expression.
|
void |
prepareDoesExist(DatabaseField field)
Pre-build the SQL statement from the expression.
|
void |
prepareInsertObject()
Pre-build the SQL statement from the expression.
|
void |
prepareReportQuerySelectAllRows()
Pre-build the SQL statement from the expression.
|
void |
prepareReportQuerySubSelect()
Pre-build the SQL statement from the expression.
|
void |
prepareSelectAllRows()
Pre-build the SQL statement from the expression.
|
void |
prepareSelectOneRow()
Pre-build the SQL statement from the expression.
|
void |
prepareUpdateAll()
Pre-build the SQL statement from the expressions.
|
protected void |
prepareUpdateAllUsingOracleAnonymousBlock(HashMap tables_databaseFieldsToValues,
HashMap tablesToPrimaryKeyFields)
Pre-build the SQL statement from the expressions.
|
protected void |
prepareUpdateAllUsingTempStorage(HashMap tables_databaseFieldsToValues,
HashMap tablesToPrimaryKeyFields) |
protected void |
prepareUpdateAllUsingTempTables(HashMap tables_databaseFieldsToValues,
HashMap tablesToPrimaryKeyFields)
Pre-build the SQL statement from the expressions.
|
void |
prepareUpdateObject()
Pre-build the SQL statement from the expression.
|
Vector |
selectAllReportQueryRows()
INTERNAL
Read all rows from the database.
|
Vector |
selectAllRows()
Read all rows from the database.
|
Vector |
selectAllRowsFromConcreteTable()
Read all rows from the database.
|
Vector |
selectAllRowsFromTable()
Read all rows from the database.
|
AbstractRecord |
selectOneRow()
Read a single row from the database.
|
AbstractRecord |
selectOneRowFromConcreteTable()
Read a single row from the database.
|
AbstractRecord |
selectOneRowFromTable()
Read a single row from the database.
|
void |
setSelectionCriteria(Expression expression)
Set the selection criteria of the query.
|
clearStatement, deleteObject, executeNoSelect, getSQLStatement, getSQLStatements, hasMultipleStatements, insertObject, insertObject, isCallQueryMechanism, prepareExecuteNoSelect, prepareExecuteSelect, setCallFromStatement, setSQLStatement, setSQLStatements, updateObject
getDatabaseCall, prepareCall, setCallHasCustomSQLArguments, updateForeignKeyFieldShallow
addCall, cursorSelectAllRows, deleteAll, deleteAllUsingTempTables, executeCall, executeCall, executeNoSelectCall, executeSelect, executeSelectCall, getCall, getCalls, hasMultipleCalls, prepareReportQueryItems, selectRowForDoesExist, setCall, setCalls, updateAll, updateAllUsingTempTables
addObjectDeletedDuringCommit, addWriteLockFieldForInsert, buildObjectsFromRows, buildSelectionCriteria, clone, deleteObjectForWrite, executeWrite, executeWriteWithChangeSet, getDescriptor, getModifyRow, getQuery, getReadObjectQuery, getSession, getTranslationRow, getWriteObjectQuery, insertObjectForWrite, insertObjectForWriteWithChangeSet, isEJBQLCallQueryMechanism, isQueryByExampleMechanism, performUserDefinedDelete, performUserDefinedInsert, performUserDefinedUpdate, performUserDefinedWrite, prepareForExecution, registerObjectInIdentityMap, setQuery, shallowDeleteObjectForWrite, shallowInsertObjectForWrite, updateChangeSet, updateChangeSet, updateChangeSet, updateChangeSet, updateForeignKeyFieldAfterInsert, updateForeignKeyFieldBeforeDelete, updateObjectAndRowWithReturnRow, updateObjectAndRowWithSequenceNumber, updateObjectForWrite, updateObjectForWriteWithChangeSet
protected Expression selectionCriteria
public ExpressionQueryMechanism(DatabaseQuery query)
query
- - owner of mechanismpublic ExpressionQueryMechanism(DatabaseQuery query, Expression expression)
query
- - owner of mechanismexpression
- - selection criteriaprotected Vector aliasFields(ObjectExpression node, Vector fields)
public Vector aliasPresetFields(SQLSelectStatement statement)
public Expression buildBaseSelectionCriteria(boolean isSubSelect, Dictionary clonedExpressions)
public SQLSelectStatement buildBaseSelectStatement(boolean isSubSelect, Dictionary clonedExpressions)
protected SQLSelectStatement buildConcreteSelectStatement()
protected SQLDeleteStatement buildDeleteAllStatement(DatabaseTable table, Expression inheritanceExpression, SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, SQLCall selectCallForNotExist, SQLSelectStatement selectStatementForNotExist, Collection primaryKeyFields)
protected SQLDeleteStatement buildDeleteAllStatementForMapping(SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, Vector sourceFields, Vector targetFields)
protected static String getAliasTableName(SQLSelectStatement selectStatement, DatabaseTable table)
protected SQLDeleteStatement buildDeleteStatementForDeleteAllQuery(DatabaseTable table)
protected SQLDeleteStatement buildDeleteStatementForDeleteAllQuery(DatabaseTable table, Expression inheritanceExpression)
protected SQLDeleteStatement buildDeleteStatement(DatabaseTable table)
protected SQLInsertStatement buildInsertStatement(DatabaseTable table)
protected SQLSelectStatement buildNormalSelectStatement()
protected SQLSelectStatement buildReportQuerySelectStatement(boolean isSubSelect)
protected SQLSelectStatement buildReportQuerySelectStatement(boolean isSubSelect, boolean useCustomaryInheritanceExpression, Expression inheritanceExpression)
protected int computeAndSetItemOffset(ReportItem item, int itemOffset)
public void extractStatementFromItem(ReportItem item, IdentityHashtable clonedExpressions, SQLSelectStatement selectStatement, Vector fieldExpressions)
protected SQLSelectStatement buildSelectStatementForDoesExist(DatabaseField field)
fields
- - fields for does exist check.protected SQLUpdateAllStatement buildUpdateAllStatement(DatabaseTable table, HashMap databaseFieldsToValues, SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, Collection primaryKeyFields)
protected SQLUpdateStatement buildUpdateStatement(DatabaseTable table)
public Object checkCacheForObject(AbstractRecord translationRow, AbstractSession session)
checkCacheForObject
in class DatabaseQueryMechanism
public DatabaseQueryMechanism clone(DatabaseQuery queryClone)
clone
in class StatementQueryMechanism
public ExpressionBuilder getExpressionBuilder()
public Expression getSelectionCriteria()
getSelectionCriteria
in class StatementQueryMechanism
public Vector getSelectionFields(SQLSelectStatement statement, boolean includeAllSubclassFields)
public Vector getNonSelectionFields()
public boolean isExpressionQueryMechanism()
isExpressionQueryMechanism
in class DatabaseQueryMechanism
public boolean isStatementQueryMechanism()
isStatementQueryMechanism
in class StatementQueryMechanism
public void prepare() throws QueryException
prepare
in class StatementQueryMechanism
QueryException
public void prepareCursorSelectAllRows()
prepareCursorSelectAllRows
in class StatementQueryMechanism
public void prepareDeleteAll()
prepareDeleteAll
in class StatementQueryMechanism
protected void prepareDeleteAll(Vector tablesToIgnore)
protected void prepareDeleteAllUsingTempStorage()
protected void prepareDeleteAllUsingTempTables()
protected Vector buildDeleteAllStatementsForMappings(SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, boolean dontCheckDescriptor)
protected Vector buildDeleteAllStatementsForMappingsWithTempTable(ClassDescriptor descriptor, DatabaseTable rootTable, Collection rootTablePrimaryKeyFields, boolean dontCheckDescriptor)
protected SQLSelectStatement createSQLSelectStatementForModifyAll(Expression whereClause)
protected SQLSelectStatement createSQLSelectStatementForModifyAll(Expression whereClause, Expression inheritanceExpression)
protected SQLSelectStatement createSQLSelectStatementForModifyAll(Expression whereClause, Expression inheritanceExpression, ClassDescriptor desc)
protected SQLSelectStatement createSQLSelectStatementForModifyAll(Expression whereClause, Expression inheritanceExpression, ClassDescriptor desc, boolean useCustomaryInheritanceExpression)
protected SQLSelectStatement createSQLSelectStatementForAssignedExpressionForUpdateAll(Expression value)
public void prepareDeleteObject()
prepareDeleteObject
in class StatementQueryMechanism
public void prepareDoesExist(DatabaseField field)
prepareDoesExist
in class StatementQueryMechanism
public void prepareInsertObject()
prepareInsertObject
in class StatementQueryMechanism
public void prepareReportQuerySelectAllRows()
prepareReportQuerySelectAllRows
in class DatasourceCallQueryMechanism
public void prepareReportQuerySubSelect()
prepareReportQuerySubSelect
in class DatasourceCallQueryMechanism
public void prepareSelectAllRows()
prepareSelectAllRows
in class StatementQueryMechanism
public void prepareSelectOneRow()
prepareSelectOneRow
in class StatementQueryMechanism
public void prepareUpdateObject()
prepareUpdateObject
in class StatementQueryMechanism
public void prepareUpdateAll()
prepareUpdateAll
in class StatementQueryMechanism
protected SQLSelectStatement createSQLSelectStatementForUpdateAllForOracleAnonymousBlock(HashMap tables_databaseFieldsToValues)
protected SQLSelectStatement createSQLSelectStatementForModifyAllForTempTable(HashMap databaseFieldsToValues)
protected SQLModifyStatement buildUpdateAllStatementForOracleAnonymousBlock(HashMap tables_databaseFieldsToValues, HashMap tablesToPrimaryKeyFields)
protected void prepareUpdateAllUsingTempStorage(HashMap tables_databaseFieldsToValues, HashMap tablesToPrimaryKeyFields)
protected void prepareUpdateAllUsingOracleAnonymousBlock(HashMap tables_databaseFieldsToValues, HashMap tablesToPrimaryKeyFields)
protected void prepareUpdateAllUsingTempTables(HashMap tables_databaseFieldsToValues, HashMap tablesToPrimaryKeyFields)
protected Vector buildStatementsForDeleteAllForTempTables()
protected Vector buildStatementsForUpdateAllForTempTables(DatabaseTable table, HashMap databaseFieldsToValues, Collection primaryKeyFields)
protected Collection getPrimaryKeyFieldsForTable(DatabaseTable table)
protected Collection getPrimaryKeyFieldsForTable(ClassDescriptor descriptor, DatabaseTable table)
public Vector selectAllReportQueryRows() throws DatabaseException
selectAllReportQueryRows
in class DatasourceCallQueryMechanism
DatabaseException
- - an error has occurred on the database.public Vector selectAllRows() throws DatabaseException
selectAllRows
in class DatasourceCallQueryMechanism
DatabaseException
- - an error has occurred on the database.public Vector selectAllRowsFromConcreteTable() throws DatabaseException
DatabaseException
public Vector selectAllRowsFromTable() throws DatabaseException
DatabaseException
- - an error has occurred on the database.public AbstractRecord selectOneRow() throws DatabaseException
selectOneRow
in class DatasourceCallQueryMechanism
DatabaseException
- - an error has occurred on the databasepublic AbstractRecord selectOneRowFromConcreteTable() throws DatabaseException
DatabaseException
public AbstractRecord selectOneRowFromTable() throws DatabaseException
fields
- - fields used to build database rowDatabaseException
- - an error has occurred on the databasepublic void setSelectionCriteria(Expression expression)
protected ClassDescriptor getHighestDescriptorMappingTable(DatabaseTable table)
Copyright © 2022. All rights reserved.