Top Description Fields Constructors Methods
org.eclipse.persistence.internal.queries

public Class ExpressionQueryMechanism

extends StatementQueryMechanism
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.internal.queries.JPQLCallQueryMechanism, org.eclipse.persistence.internal.queries.QueryByExampleMechanism
Imports
java.util.ArrayList, .Collection, .Enumeration, .HashMap, .HashSet, .IdentityHashMap, .Iterator, .List, .Map, .Set, .Vector, org.eclipse.persistence.descriptors.ClassDescriptor, .DescriptorQueryManager, .InheritancePolicy, org.eclipse.persistence.exceptions.DatabaseException, .QueryException, org.eclipse.persistence.expressions.Expression, .ExpressionBuilder, org.eclipse.persistence.internal.databaseaccess.DatabaseCall, .DatasourceCall, .DatasourcePlatform, org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy, org.eclipse.persistence.internal.expressions.ConstantExpression, .DataExpression, .ExpressionIterator, .FieldExpression, .ObjectExpression, .ParameterExpression, .QueryKeyExpression, .SQLDeleteAllStatement, .SQLDeleteAllStatementForTempTable, .SQLDeleteStatement, .SQLInsertStatement, .SQLModifyAllStatementForTempTable, .SQLModifyStatement, .SQLSelectStatement, .SQLStatement, .SQLUpdateAllStatement, .SQLUpdateAllStatementForOracleAnonymousBlock, .SQLUpdateAllStatementForTempTable, .SQLUpdateStatement, org.eclipse.persistence.internal.helper.DatabaseField, .DatabaseTable, .Helper, .InvalidObject, .NonSynchronizedVector, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .UnitOfWorkImpl, org.eclipse.persistence.logging.SessionLog, org.eclipse.persistence.mappings.AggregateCollectionMapping, .DatabaseMapping, .DirectCollectionMapping, .ForeignReferenceMapping, .ManyToManyMapping, .OneToOneMapping, .RelationTableMechanism, org.eclipse.persistence.queries.ConstructorReportItem, .DatabaseQuery, .DeleteAllQuery, .DeleteObjectQuery, .FetchGroup, .InMemoryQueryIndirectionPolicy, .ModifyAllQuery, .ObjectLevelReadQuery, .ReadAllQuery, .ReadObjectQuery, .ReportQuery, .SQLCall, .UpdateAllQuery

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.

Author
Yvon Lavoie
Since
TOPLink/Java 1.0

Field Summary

Modifier and TypeField and Description
protected Expression
Inherited from org.eclipse.persistence.internal.queries.StatementQueryMechanism:
sqlStatementsqlStatements

Constructor Summary

AccessConstructor and Description
public
public
ExpressionQueryMechanism(DatabaseQuery
- owner of mechanism
query
)

Initialize the state of the query

public
ExpressionQueryMechanism(DatabaseQuery
- owner of mechanism
query
,
Expression
- selection criteria
expression
)

Initialize the state of the query

Method Summary

Modifier and TypeMethod and Description
protected Vector<E>
aliasFields(ObjectExpression node, Vector<E> fields)

Alias the supplied fields with respect to the expression node.

public Vector<E>
aliasPresetFields(SQLSelectStatement statement)

If the fields in the statement have breen pre-set, e.g. for a subset of the fields in a partial attribute read, report query, or just a query for the class indicator, then try to alias those.

public Expression
buildBaseSelectionCriteria(boolean isSubSelect, Map<K, V> clonedExpressions)

Create the appropriate where clause.

public Expression
buildBaseSelectionCriteria(boolean isSubSelect, Map<K, V> clonedExpressions, boolean shouldUseAdditionalJoinExpression)

Create the appropriate where clause.

public SQLSelectStatement
buildBaseSelectStatement(boolean isSubSelect, Map<K, V> clonedExpressions)

Return the appropriate select statement containing the fields in the table.

public SQLSelectStatement
buildBaseSelectStatement(boolean isSubSelect, Map<K, V> clonedExpressions, boolean shouldUseAdditionalJoinExpression)

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

Returns:

SQLDeleteStatement
buildDeleteAllStatement
(DatabaseTable table, Expression inheritanceExpression, SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, SQLCall selectCallForNotExist, SQLSelectStatement selectStatementForNotExist, Collection<E> 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

Returns:

Vector<SQLDeleteAllStatement>
buildDeleteAllStatementForMapping
(SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, Vector<E> sourceFields, Vector<E> targetFields)

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.

private SQLDeleteAllStatementForTempTable

Returns:

SQLDeleteAllStatementForTempTable
buildDeleteAllStatementForTempTable
(DatabaseTable rootTable, List<DatabaseField> rootTablePrimaryKeyFields, DatabaseTable targetTable, List<DatabaseField> targetTablePrimaryKeyFields)

Build SQL delete statement which delete from target table using temporary table.

protected Vector<E>

Returns:

Vector<SQLDeleteAllStatement>
buildDeleteAllStatementsForMappings
(SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, boolean dontCheckDescriptor)

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<E>

Returns:

Vector<SQLDeleteAllStatementForTempTable>
buildDeleteAllStatementsForMappingsWithTempTable
(ClassDescriptor descriptor, DatabaseTable rootTable, boolean dontCheckDescriptor)

Build delete statements with temporary table for ManyToMany and DirectCollection mappings.

private Vector<E>

Returns:

Vector<SQLDeleteAllStatementForTempTable>
buildDeleteAllStatementsForTempTable
(ClassDescriptor descriptor, DatabaseTable rootTable, List<DatabaseField> rootTablePrimaryKeyFields, Vector<E> tablesToIgnore)

Build delete all SQLStatements using temporary table.

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, boolean shouldUseAdditionalJoinExpression)

Customary inheritance expression is required for DeleteAllQuery and UpdateAllQuery preparation.

protected SQLSelectStatement
buildSelectStatementForDoesExist(DatabaseField
fields for does exist check.
field
)

Return the appropriate select statement to perform a does exist check

protected Vector<E>

Returns:

Vector<SQLStatement>
buildStatementsForDeleteAllForTempTables
()

Build SQLStatements for delete all using temporary table.

protected Vector<E>
buildStatementsForUpdateAllForTempTables(DatabaseTable table, HashMap<K, V> databaseFieldsToValues, List<DatabaseField> primaryKeyFields)

protected SQLUpdateAllStatement
buildUpdateAllStatement(DatabaseTable table, HashMap<K, V> databaseFieldsToValues, SQLCall selectCallForExist, SQLSelectStatement selectStatementForExist, Collection<E> primaryKeyFields)

protected SQLModifyStatement
buildUpdateAllStatementForOracleAnonymousBlock(HashMap<K, V> tables_databaseFieldsToValues, HashMap<K, V> tablesToPrimaryKeyFields)

protected SQLUpdateStatement

Returns:

SQLInsertStatement
buildUpdateStatement
(DatabaseTable table)

Return the appropriate update statement

public Object
checkCacheForObject(AbstractRecord translationRow, AbstractSession session)

Overrides org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.checkCacheForObject.

Perform a cache lookup for the query This is only called from read object query.
public void
clearStatement()

Overrides org.eclipse.persistence.internal.queries.StatementQueryMechanism.clearStatement.

The statement is no longer require after prepare so can be released.
public DatabaseQueryMechanism
clone(DatabaseQuery queryClone)

Overrides org.eclipse.persistence.internal.queries.StatementQueryMechanism.clone.

Clone the mechanism for the specified query clone.
private List<Expression>
cloneExpressions(List<Expression> originalExpressions, Map<Expression, Expression> clonedExpressions)

This method return the clones of the list of expressions.

private void
computeFieldExpressions(List<ReportItem> items, Map<K, V> clonedExpressions, SQLSelectStatement selectStatement, Vector<E> fieldExpressions)

protected SQLSelectStatement
protected SQLSelectStatement
protected SQLSelectStatement
createSQLSelectStatementForModifyAll(Expression whereClause, Expression inheritanceExpression, ClassDescriptor desc, boolean useCustomaryInheritanceExpression, boolean shouldUseAdditionalJoinExpression)

Customary inheritance expression is required for DeleteAllQuery and UpdateAllQuery preparation.

protected SQLSelectStatement
protected SQLSelectStatement
private void
extractStatementFromItem(ReportItem item, Map<K, V> clonedExpressions, SQLSelectStatement selectStatement, Vector<E> fieldExpressions)

protected static String
public 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.

protected List<DatabaseField>
protected List<DatabaseField>
public Expression
public Vector<E>
getSelectionFields(SQLSelectStatement statement, boolean includeAllSubclassFields)

Return the fields required in the select clause.

public boolean
private boolean
isFieldInUpdate(Expression writeLock, HashMap<K, V> updateClauses)

public boolean
public void
public void
public void
protected void
prepareDeleteAll(List<DatabaseTable> tablesToIgnore, boolean isWhereClauseRequired)

Pre-build the SQL statement from the expression.

protected void
protected void
public void
public void
public void
public void
public void
public void
public void
public void
protected void
prepareUpdateAllUsingOracleAnonymousBlock(HashMap<K, V> tables_databaseFieldsToValues, HashMap<K, V> tablesToPrimaryKeyFields)

Pre-build the SQL statement from the expressions.

protected void
prepareUpdateAllUsingTempStorage(HashMap<K, V> tables_databaseFieldsToValues, HashMap<DatabaseTable, List<DatabaseField>> tablesToPrimaryKeyFields)

protected void
prepareUpdateAllUsingTempTables(HashMap<K, V> tables_databaseFieldsToValues, HashMap<DatabaseTable, List<DatabaseField>> tablesToPrimaryKeyFields)

Pre-build the SQL statement from the expressions.

public void
public Vector<E>

Returns:

Vector containing the database rows.
selectAllReportQueryRows
()

Overrides org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllReportQueryRows.

INTERNAL Read all rows from the database.
public Vector<E>

Returns:

Vector containing the database rows.
selectAllRows
()

Overrides org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows.

Read all rows from the database.
public Vector<E>
selectAllRowsFromConcreteTable()

Read all rows from the database.

public Vector<E>

Returns:

Vector containing the database rows.
selectAllRowsFromTable
()

Read all rows from the database.

public AbstractRecord
public AbstractRecord
selectOneRowFromConcreteTable()

Read a single row from the database.

public AbstractRecord
selectOneRowFromTable()

Read a single row from the database.

public void
setSelectionCriteria(Expression expression)

Set the selection criteria of the query.

protected boolean
shouldBuildDeleteStatementForMapping(ForeignReferenceMapping frMapping, boolean dontCheckDescriptor, ClassDescriptor descriptor)

protected boolean
shouldIncludeAllSubclassFields(SQLSelectStatement selectStatement)

Return whether to include all subclass fields in select statement or not.

Inherited from org.eclipse.persistence.internal.queries.StatementQueryMechanism:
configureDatabaseCalldeleteObjectexecuteNoSelectgetSQLStatementgetSQLStatementshasMultipleStatementsinsertObjectinsertObjectisCallQueryMechanismprepareExecuteNoSelectprepareExecuteSelectsetCallFromStatementsetSQLStatementsetSQLStatementstrimFieldsForInsertupdateObject