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

public Class QueryByExampleMechanism

extends ExpressionQueryMechanism
Class Inheritance
Imports
java.util.*, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.expressions.*, org.eclipse.persistence.exceptions.*, org.eclipse.persistence.queries.*

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.

Author
Stephen McRitchie
Since
9.0.3.5

Field Summary

Modifier and TypeField and Description
protected Object
exampleObject

Used for Query By Example.

protected boolean
protected QueryByExamplePolicy
Inherited from org.eclipse.persistence.internal.queries.ExpressionQueryMechanism:
selectionCriteria

Constructor Summary

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

Initialize the state of the query

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

Initialize the state of the query

Method Summary

Modifier and TypeMethod and Description
public void
buildSelectionCriteria(AbstractSession session)

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

INTERNAL: In the case of EJBQL or query by example, an expression needs to be generated.
public Object
getExampleObject()

PUBLIC: This method returns the current example object.

public QueryByExamplePolicy
getQueryByExamplePolicy()

PUBLIC: When using Query By Example, an instance of QueryByExamplePolicy is used to customize the query.

public boolean
isParsed()

INTERNAL: Is this query Parsed

public boolean
public void
setExampleObject(Object newExampleObject)

PUBLIC: Set the example object of the query to be the newExampleObject.

public void
setIsParsed(boolean newIsParsed)

INTERNAL: Set the isParsed state

public void
setQueryByExamplePolicy(QueryByExamplePolicy queryByExamplePolicy)

PUBLIC: The QueryByExamplePolicy, is a useful to customize the query when Query By Example is used.

Inherited from org.eclipse.persistence.internal.queries.ExpressionQueryMechanism:
aliasFieldsaliasPresetFieldsbuildBaseSelectionCriteriabuildBaseSelectionCriteriabuildBaseSelectStatementbuildBaseSelectStatementbuildConcreteSelectStatementbuildDeleteAllStatementbuildDeleteAllStatementForMappingbuildDeleteAllStatementsForMappingsbuildDeleteAllStatementsForMappingsWithTempTablebuildDeleteStatementbuildDeleteStatementForDeleteAllQuerybuildDeleteStatementForDeleteAllQuerybuildInsertStatementbuildNormalSelectStatementbuildReportQuerySelectStatementbuildReportQuerySelectStatementbuildSelectStatementForDoesExistbuildStatementsForDeleteAllForTempTablesbuildStatementsForUpdateAllForTempTablesbuildUpdateAllStatementbuildUpdateAllStatementForOracleAnonymousBlockbuildUpdateStatementcheckCacheForObjectclearStatementclonecreateSQLSelectStatementForAssignedExpressionForUpdateAllcreateSQLSelectStatementForModifyAllcreateSQLSelectStatementForModifyAllcreateSQLSelectStatementForModifyAllForTempTablecreateSQLSelectStatementForUpdateAllForOracleAnonymousBlockgetAliasTableNamegetExpressionBuildergetHighestDescriptorMappingTablegetPrimaryKeyFieldsForTablegetPrimaryKeyFieldsForTablegetSelectionCriteriagetSelectionFieldsisExpressionQueryMechanismisStatementQueryMechanismprepareprepareCursorSelectAllRowsprepareDeleteAllprepareDeleteAllprepareDeleteAllUsingTempStorageprepareDeleteAllUsingTempTablesprepareDeleteObjectprepareDoesExistprepareInsertObjectprepareReportQuerySelectAllRowsprepareReportQuerySubSelectprepareSelectAllRowsprepareSelectOneRowprepareUpdateAllprepareUpdateAllUsingOracleAnonymousBlockprepareUpdateAllUsingTempStorageprepareUpdateAllUsingTempTablesprepareUpdateObjectselectAllReportQueryRowsselectAllRowsselectAllRowsFromConcreteTableselectAllRowsFromTableselectOneRowselectOneRowFromConcreteTableselectOneRowFromTablesetSelectionCriteriashouldBuildDeleteStatementForMappingshouldIncludeAllSubclassFields

Field Detail

exampleObjectback to summary
protected Object exampleObject

Used for Query By Example.

isParsedback to summary
protected boolean isParsed
queryByExamplePolicyback to summary
protected QueryByExamplePolicy queryByExamplePolicy

Constructor Detail

QueryByExampleMechanismback to summary
public QueryByExampleMechanism(DatabaseQuery query)

Initialize the state of the query

Parameters
query:DatabaseQuery

- owner of mechanism

QueryByExampleMechanismback to summary
public QueryByExampleMechanism(DatabaseQuery query, Expression expression)

Initialize the state of the query

Parameters
query:DatabaseQuery

- owner of mechanism

expression:Expression

- selection criteria

Method Detail

buildSelectionCriteriaback to summary
public void buildSelectionCriteria(AbstractSession session)

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

INTERNAL: In the case of EJBQL or query by example, an expression needs to be generated. Build the required expression.

Annotations
@Override
getExampleObjectback to summary
public 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.

getQueryByExamplePolicyback to summary
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.

isParsedback to summary
public boolean isParsed()

INTERNAL: Is this query Parsed

isQueryByExampleMechanismback to summary
public boolean isQueryByExampleMechanism()

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

Return true if this is a query by example mechanism

Annotations
@Override
setExampleObjectback to summary
public void setExampleObject(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.

setIsParsedback to summary
public void setIsParsed(boolean newIsParsed)

INTERNAL: Set the isParsed state

setQueryByExamplePolicyback to summary
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.