Class QueryByExampleMechanism
- java.lang.Object
-
- org.eclipse.persistence.internal.queries.DatabaseQueryMechanism
-
- org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism
-
- org.eclipse.persistence.internal.queries.CallQueryMechanism
-
- org.eclipse.persistence.internal.queries.StatementQueryMechanism
-
- org.eclipse.persistence.internal.queries.ExpressionQueryMechanism
-
- org.eclipse.persistence.internal.queries.QueryByExampleMechanism
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class QueryByExampleMechanism extends ExpressionQueryMechanism
Purpose: Mechanism used for all queries by example.
Responsibilities: Builds a selection criteria for this query given an example object and a QueryByExample policy. Works akin to EBQLMechanism which builds the selection criteria from an EJBQL string.
- Since:
- 9.0.3.5
- Author:
- Stephen McRitchie
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object
exampleObject
Used for Query By Example.protected boolean
isParsed
protected QueryByExamplePolicy
queryByExamplePolicy
-
Fields inherited from class org.eclipse.persistence.internal.queries.ExpressionQueryMechanism
selectionCriteria
-
Fields inherited from class org.eclipse.persistence.internal.queries.StatementQueryMechanism
sqlStatement, sqlStatements
-
Fields inherited from class org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism
call, calls
-
Fields inherited from class org.eclipse.persistence.internal.queries.DatabaseQueryMechanism
query
-
-
Constructor Summary
Constructors Constructor Description QueryByExampleMechanism(DatabaseQuery query)
Initialize the state of the queryQueryByExampleMechanism(DatabaseQuery query, Expression expression)
Initialize the state of the query
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildSelectionCriteria(AbstractSession session)
INTERNAL: In the case of EJBQL or query by example, an expression needs to be generated.java.lang.Object
getExampleObject()
PUBLIC: This method returns the current example object.QueryByExamplePolicy
getQueryByExamplePolicy()
PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query.boolean
isParsed()
INTERNAL: Is this query Parsedboolean
isQueryByExampleMechanism()
Return true if this is a query by example mechanismvoid
setExampleObject(java.lang.Object newExampleObject)
PUBLIC: Set the example object of the query to be the newExampleObject.void
setIsParsed(boolean newIsParsed)
INTERNAL: Set the isParsed statevoid
setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)
PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used.-
Methods inherited from class org.eclipse.persistence.internal.queries.ExpressionQueryMechanism
aliasFields, aliasPresetFields, buildBaseSelectionCriteria, buildBaseSelectionCriteria, buildBaseSelectStatement, buildBaseSelectStatement, buildConcreteSelectStatement, buildDeleteAllStatement, buildDeleteAllStatementForMapping, buildDeleteAllStatementsForMappings, buildDeleteAllStatementsForMappingsWithTempTable, buildDeleteStatement, buildDeleteStatementForDeleteAllQuery, buildDeleteStatementForDeleteAllQuery, buildInsertStatement, buildNormalSelectStatement, buildReportQuerySelectStatement, buildReportQuerySelectStatement, buildSelectStatementForDoesExist, buildStatementsForDeleteAllForTempTables, buildStatementsForUpdateAllForTempTables, buildUpdateAllStatement, buildUpdateAllStatementForOracleAnonymousBlock, buildUpdateStatement, checkCacheForObject, clearStatement, clone, createSQLSelectStatementForAssignedExpressionForUpdateAll, createSQLSelectStatementForModifyAll, createSQLSelectStatementForModifyAll, createSQLSelectStatementForModifyAllForTempTable, createSQLSelectStatementForUpdateAllForOracleAnonymousBlock, getAliasTableName, getExpressionBuilder, getHighestDescriptorMappingTable, getPrimaryKeyFieldsForTable, getPrimaryKeyFieldsForTable, getSelectionCriteria, getSelectionFields, isExpressionQueryMechanism, isStatementQueryMechanism, prepare, prepareCursorSelectAllRows, prepareDeleteAll, prepareDeleteAll, prepareDeleteAllUsingTempStorage, prepareDeleteAllUsingTempTables, prepareDeleteObject, prepareDoesExist, prepareInsertObject, prepareReportQuerySelectAllRows, prepareReportQuerySubSelect, prepareSelectAllRows, prepareSelectOneRow, prepareUpdateAll, prepareUpdateAllUsingOracleAnonymousBlock, prepareUpdateAllUsingTempStorage, prepareUpdateAllUsingTempTables, prepareUpdateObject, selectAllReportQueryRows, selectAllRows, selectAllRowsFromConcreteTable, selectAllRowsFromTable, selectOneRow, selectOneRowFromConcreteTable, selectOneRowFromTable, setSelectionCriteria, shouldBuildDeleteStatementForMapping, shouldIncludeAllSubclassFields
-
Methods inherited from class org.eclipse.persistence.internal.queries.StatementQueryMechanism
configureDatabaseCall, deleteObject, executeNoSelect, getSQLStatement, getSQLStatements, hasMultipleStatements, insertObject, insertObject, isCallQueryMechanism, prepareExecuteNoSelect, prepareExecuteSelect, setCallFromStatement, setSQLStatement, setSQLStatements, trimFieldsForInsert, updateObject
-
Methods inherited from class org.eclipse.persistence.internal.queries.CallQueryMechanism
getDatabaseCall, prepareCall, prepareExecute, prepareJoining, setCallHasCustomSQLArguments, unprepare, updateForeignKeyFieldAfterInsert, updateForeignKeyFieldBeforeDelete
-
Methods inherited from class org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism
addCall, computeAndSetItemOffset, cursorSelectAllRows, deleteAll, deleteAllUsingTempTables, execute, executeCall, executeCall, executeDeferredCall, executeNoSelectCall, executeSelect, executeSelectCall, generateKeysExecuteNoSelect, getCall, getCalls, hasMultipleCalls, prepareReportQueryItems, selectResultSet, selectRowForDoesExist, setCall, setCalls, updateAll, updateAllUsingTempTables
-
Methods inherited from class org.eclipse.persistence.internal.queries.DatabaseQueryMechanism
addWriteLockFieldForInsert, clone, executeWrite, executeWriteWithChangeSet, getDescriptor, getExecutionSession, getModifyRow, getQuery, getReadObjectQuery, getSession, getTranslationRow, getWriteObjectQuery, insertObjectForWrite, isJPQLCallQueryMechanism, performUserDefinedInsert, performUserDefinedUpdate, performUserDefinedWrite, registerObjectInIdentityMap, setQuery, shallowInsertObjectForWrite, updateForeignKeyFieldAfterInsert, updateObjectAndRowWithReturnRow, updateObjectAndRowWithSequenceNumber, updateObjectAndRowWithSequenceNumber, updateObjectForWrite, updateObjectForWriteWithChangeSet
-
-
-
-
Field Detail
-
isParsed
protected boolean isParsed
-
exampleObject
protected java.lang.Object exampleObject
Used for Query By Example.
-
queryByExamplePolicy
protected QueryByExamplePolicy queryByExamplePolicy
-
-
Constructor Detail
-
QueryByExampleMechanism
public QueryByExampleMechanism(DatabaseQuery query)
Initialize the state of the query- Parameters:
query
- - owner of mechanism
-
QueryByExampleMechanism
public QueryByExampleMechanism(DatabaseQuery query, Expression expression)
Initialize the state of the query- Parameters:
query
- - owner of mechanismexpression
- - selection criteria
-
-
Method Detail
-
buildSelectionCriteria
public void buildSelectionCriteria(AbstractSession session)
INTERNAL: In the case of EJBQL or query by example, an expression needs to be generated. Build the required expression.- Overrides:
buildSelectionCriteria
in classDatabaseQueryMechanism
-
getExampleObject
public java.lang.Object getExampleObject()
PUBLIC: This method returns the current example object. The "example" object is an actual domain object, provided by the client, from which an expression is generated. This expression is used for a query of all objects from the same class, that match the attribute values of the "example" object.
-
getQueryByExamplePolicy
public QueryByExamplePolicy getQueryByExamplePolicy()
PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query. The policy is useful when special operations are to be used for comparisons (notEqual, lessThan, greaterThan, like etc.), when a certain value is to be ignored, or when dealing with nulls.
-
isParsed
public boolean isParsed()
INTERNAL: Is this query Parsed
-
isQueryByExampleMechanism
public boolean isQueryByExampleMechanism()
Return true if this is a query by example mechanism- Overrides:
isQueryByExampleMechanism
in classDatabaseQueryMechanism
-
setExampleObject
public void setExampleObject(java.lang.Object newExampleObject)
PUBLIC: Set the example object of the query to be the newExampleObject. The example object is used for Query By Example. When doing a Query By Example, an instance of the desired object is created, and the fields are filled with the values that are required in the result set. From these values the corresponding expression is build by TopLink, and the query is executed, returning the set of results.
-
setIsParsed
public void setIsParsed(boolean newIsParsed)
INTERNAL: Set the isParsed state
-
setQueryByExamplePolicy
public void setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)
PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used. The pollicy will control what attributes should, or should not be included in the query. When dealing with nulls, using specail operations (notEqual, lessThan, like, etc.) for comparison, or chosing to include certain attributes at all times, it is useful to modify the policy accordingly.
-
-