Purpose: Concrete class for all read queries involving a single object.
Responsibilities: Return a single object for the query. Implements the inheritance feature when dealing with abstract descriptors.
| Modifier and Type | Field and Description |
|---|---|
| protected Object | selectionId
Key that can be used in place of a selection criteria. |
| protected transient Object | selectionObject
Object that can be used in place of a selection criteria. |
| protected boolean | shouldLoadResultIntoSelectionObject
Can be used to refresh a specific non-cached instance from the database. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | ReadObjectQuery(Class<?> classToRead, Expression selectionCriteria)
PUBLIC: Return a new read object query for the class and the selection criteria. |
| public | ReadObjectQuery(Class<?> classToRead, ExpressionBuilder builder)
PUBLIC: Return a new read object query for the class. |
| public | |
| public | |
| public | ReadObjectQuery(Object objectToRead)
PUBLIC: Return a query to read the object with the same primary key as the provided object. |
| public | ReadObjectQuery(Object exampleObject, QueryByExamplePolicy policy)
PUBLIC: Return a query by example query to find an object matching the attributes of the example object. |
| public | ReadObjectQuery(ExpressionBuilder builder)
PUBLIC: The expression builder should be provide on creation to ensure only one is used. |
| Modifier and Type | Method and Description |
|---|---|
| public void | cacheResult(Object object)
Implements abstract org. This method is called by the object builder when building an original. |
| public void | checkCacheByExactPrimaryKey()
PUBLIC: The cache will be checked only if the query contains exactly the primary key. |
| public void | checkCacheByPrimaryKey()
PUBLIC: This is the default, the cache will be checked only if the query contains the primary key. |
| public void | checkCacheThenDatabase()
PUBLIC: The cache will be checked completely, then if the object is not found or the query too complex the database will be queried. |
| protected Boolean | Returns: Current custom query flag. Value will never benull.Current session. session, final AbstractRecord Database record. translationRow)Implements abstract org. |
| public void | checkDescriptor(AbstractSession
Current session. session)Overrides org. |
| protected Object | checkEarlyReturnLocal(AbstractSession session, AbstractRecord translationRow)
Implements abstract org. |
| public void | |
| protected Object | conformResult(Object result, UnitOfWorkImpl unitOfWork, AbstractRecord databaseRow, boolean buildDirectlyFromRows)
INTERNAL: Conform the result in the UnitOfWork. |
| public void | copyFromQuery(DatabaseQuery query)
Overrides org. |
| public void | dontLoadResultIntoSelectionObject()
PUBLIC: Do not refesh/load into the selection object, this is the default. |
| public Object | Returns: An object or vector, the result of executing the query.the session in which the receiver will be executed. session, AbstractRecord row)Overrides org. |
| protected Object | Returns: object - the first object found or null if none.Implements abstract org. |
| protected Object | Returns: object - the first object found or null if none.Implements abstract org. |
| public Object | extractRemoteResult(Transporter transporter)
Overrides org. |
| protected QueryRedirector | getDefaultRedirector()
Overrides org. |
| protected Object | Returns: the selection id of this ReadObjectQueryOverrides org. |
| protected ObjectLevelReadQuery | Returns: Custom single object read query from query manager.Implements abstract org. |
| public Object | |
| public Object | |
| protected boolean | hasNonDefaultFetchGroup()
INTERNAL: Return if the query has an non-default fetch group defined for itself. |
| public boolean | isPrimaryKeyQuery()
Overrides org. |
| public boolean | isReadObjectQuery()
Overrides org. |
| public void | loadResultIntoSelectionObject()
PUBLIC: Allow for the selection object of the query to be refreshed or put into the EclipseLink cache. |
| protected void | prepare()
Overrides org. |
| protected void | prepareCustomQuery(DatabaseQuery customQuery)
Overrides org. |
| public void | prepareForExecution()
Overrides org. |
| protected void | prePrepare()
Overrides org. |
| public Object | Returns: the final (conformed, refreshed, wrapped) UnitOfWork query resultmay be collection (read all) or an object (read one),
or even a cursor. If in transaction the shared cache will
be bypassed, meaning the result may not be originals from the parent
but raw database rows. result, UnitOfWorkImpl the unitOfWork the result is being registered in. unitOfWork, AbstractRecord the original arguments/parameters passed to the query
execution. Used by conforming arguments, boolean If in transaction must construct
a registered result from raw database rows. buildDirectlyFromRows)Implements abstract org. |
| protected Object | |
| public Map | replaceValueHoldersIn(Object object, RemoteSessionController controller)
Overrides org. |
| public void | |
| public void | |
| public void | setShouldLoadResultIntoSelectionObject(boolean shouldLoadResultIntoSelectionObject)
PUBLIC: Allow for the selection object of the query to be refreshed or put into the EclipseLink cache. |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | shouldLoadResultIntoSelectionObject()
PUBLIC: return true if the result should be loaded into the passed in selection Object |
| selectionId | back to summary |
|---|---|
| protected Object selectionId Key that can be used in place of a selection criteria. | |
| selectionObject | back to summary |
|---|---|
| protected transient Object selectionObject Object that can be used in place of a selection criteria. | |
| shouldLoadResultIntoSelectionObject | back to summary |
|---|---|
| protected boolean shouldLoadResultIntoSelectionObject Can be used to refresh a specific non-cached instance from the database. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery() PUBLIC: Return a new read object query. A reference class must be specified before execution. It is better to provide the class and expression builder on construction to esnure a single expression builder is used. If no selection criteria is specified this will reads the first object found in the database. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(Class<?> classToRead) PUBLIC:
Return a new read object query.
By default, the query has no selection criteria. Executing this query without
selection criteria will always result in a database access to read the first
instance of the specified Class found in the database. This is true no
matter how cache usage is configured and even if an instance of the
specified Class exists in the cache.
Executing a query with selection criteria allows you to avoid a database
access if the selected instance is in the cache. For this reason, you may whish to use a ReadObjectQuery constructor that takes selection criteria, such as: | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(Class<?> classToRead, Expression selectionCriteria) PUBLIC: Return a new read object query for the class and the selection criteria. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(Class<?> classToRead, ExpressionBuilder builder) PUBLIC: Return a new read object query for the class. The expression builder must be used for all associated expressions used with the query. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(Class<?> classToRead, Call call) PUBLIC: Return a new read object query. The call represents a database interaction such as SQL, Stored Procedure. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(Call call) PUBLIC: Return a new read object query. The call represents a database interaction such as SQL, Stored Procedure. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(Object objectToRead) PUBLIC: Return a query to read the object with the same primary key as the provided object. Note This is not a query by example object, only the primary key will be used for the selection criteria. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(Object exampleObject, QueryByExamplePolicy policy) PUBLIC: Return a query by example query to find an object matching the attributes of the example object. | |
| ReadObjectQuery | back to summary |
|---|---|
| public ReadObjectQuery(ExpressionBuilder builder) PUBLIC: The expression builder should be provide on creation to ensure only one is used. | |
| cacheResult | back to summary |
|---|---|
| public void cacheResult(Object object) Implements abstract org. INTERNAL: This method is called by the object builder when building an original. It will cause the original to be cached in the query results if the query is set to do so.
| |
| checkCacheByExactPrimaryKey | back to summary |
|---|---|
| public void checkCacheByExactPrimaryKey() PUBLIC: The cache will be checked only if the query contains exactly the primary key. Queries can be configured to use the cache at several levels. Other caching option are available.
| |
| checkCacheByPrimaryKey | back to summary |
|---|---|
| public void checkCacheByPrimaryKey() PUBLIC: This is the default, the cache will be checked only if the query contains the primary key. Queries can be configured to use the cache at several levels. Other caching option are available.
| |
| checkCacheThenDatabase | back to summary |
|---|---|
| public void checkCacheThenDatabase() PUBLIC: The cache will be checked completely, then if the object is not found or the query too complex the database will be queried. Queries can be configured to use the cache at several levels. Other caching option are available.
| |
| checkCustomQueryFlag | back to summary |
|---|---|
| protected Boolean checkCustomQueryFlag(final AbstractSession session, final AbstractRecord translationRow) Implements abstract org. INTERNAL:
Check and return custom query flag. Custom query flag value is initialized when stored value is
| |
| checkDescriptor | back to summary |
|---|---|
| public void checkDescriptor(AbstractSession session) throws QueryException Overrides org. INTERNAL: Ensure that the descriptor has been set.
| |
| checkEarlyReturnLocal | back to summary |
|---|---|
| protected Object checkEarlyReturnLocal(AbstractSession session, AbstractRecord translationRow) Implements abstract org. INTERNAL: The cache check is done before the prepare as a hit will not require the work to be done.
| |
| clearSelectionId | back to summary |
|---|---|
| public void clearSelectionId() INTERNAL: Clear the selection id and object. This is done after cloning queries to prepare them in inheritance. | |
| conformResult | back to summary |
|---|---|
| protected Object conformResult(Object result, UnitOfWorkImpl unitOfWork, AbstractRecord databaseRow, boolean buildDirectlyFromRows) INTERNAL: Conform the result in the UnitOfWork. | |
| copyFromQuery | back to summary |
|---|---|
| public void copyFromQuery(DatabaseQuery query) Overrides org. INTERNAL: Copy all setting from the query. This is used to morph queries from one type to the other. By default this calls prepareFromQuery, but additional properties may be required to be copied as prepareFromQuery only copies properties that affect the SQL.
| |
| dontLoadResultIntoSelectionObject | back to summary |
|---|---|
| public void dontLoadResultIntoSelectionObject() PUBLIC: Do not refesh/load into the selection object, this is the default. This property allows for the selection object of the query to be refreshed or put into the TopLink cache. By default on a read or refresh the object in the cache is refreshed and returned or a new object is built from the database, in some cases such as EJB BMP it is desirable to refresh or load into the object passed into the read object query. Note This forces the selection object into the cache a replaces any existing object that may already be there, this is a strict violation of object identity and other objects can still be refering to the old object. | |
| execute | back to summary |
|---|---|
| public Object execute(AbstractSession session, AbstractRecord row) throws DatabaseException Overrides org. INTERNAL: Execute the query. If there are cached results return those. This must override the super to support result caching.
| |
| executeObjectLevelReadQuery | back to summary |
|---|---|
| protected Object executeObjectLevelReadQuery() throws DatabaseException Implements abstract org. INTERNAL: Execute the query. Do a cache lookup and build object from row if required.
| |
| executeObjectLevelReadQueryFromResultSet | back to summary |
|---|---|
| protected Object executeObjectLevelReadQueryFromResultSet() throws DatabaseException Implements abstract org. INTERNAL: Execute the query building the objects directly from the database result-set.
| |
| extractRemoteResult | back to summary |
|---|---|
| public Object extractRemoteResult(Transporter transporter) Overrides org. INTERNAL: Extract the correct query result from the transporter.
| |
| getDefaultRedirector | back to summary |
|---|---|
| protected QueryRedirector getDefaultRedirector() Overrides org. INTERNAL: Returns the specific default redirector for this query type. There are numerous default query redirectors. See ClassDescriptor for their types.
| |
| getQueryPrimaryKey | back to summary |
|---|---|
| protected Object getQueryPrimaryKey() Overrides org. INTERNAL: Return the primary key stored in this query | |
| getReadQuery | back to summary |
|---|---|
| protected ObjectLevelReadQuery getReadQuery() Implements abstract org. INTERNAL:
Get custom single object read query from query manager.
Called from
| |
| getSelectionId | back to summary |
|---|---|
| public Object getSelectionId() PUBLIC: Return Id of the object to be selected by the query. | |
| getSelectionObject | back to summary |
|---|---|
| public Object getSelectionObject() PUBLIC: Return the selection object of the query. This can be used instead of a where clause expression for single object primary key queries. The selection object given should have a primary key defined, this primary key will be used to query the database instance of the same object. This is a basic form of query by example where only the primary key is required, it can be used for simple query forms, or testing. | |
| hasNonDefaultFetchGroup | back to summary |
|---|---|
| protected boolean hasNonDefaultFetchGroup() INTERNAL: Return if the query has an non-default fetch group defined for itself. | |
| isPrimaryKeyQuery | back to summary |
|---|---|
| public boolean isPrimaryKeyQuery() Overrides org. INTERNAL: Return if the query is by primary key.
| |
| isReadObjectQuery | back to summary |
|---|---|
| public boolean isReadObjectQuery() Overrides org. PUBLIC: Return if this is a read object query.
| |
| loadResultIntoSelectionObject | back to summary |
|---|---|
| public void loadResultIntoSelectionObject() PUBLIC: Allow for the selection object of the query to be refreshed or put into the EclipseLink cache. By default on a read or refresh the object in the cache is refreshed and returned or a new object is built from the database, in some cases such as EJB BMP it is desirable to refresh or load into the object passed into the read object query. Note This forces the selection object into the cache a replaces any existing object that may already be there, this is a strict violation of object identity and other objects can still be referring to the old object. | |
| prepare | back to summary |
|---|---|
| protected void prepare() throws QueryException Overrides org. INTERNAL: Prepare the receiver for execution in a session.
| |
| prepareCustomQuery | back to summary |
|---|---|
| protected void prepareCustomQuery(DatabaseQuery customQuery) Overrides org. INTERNAL: Set the properties needed to be cascaded into the custom query including the translation row. This is used only for primary key queries, as the descriptor query manager stores a predefined query for this query to avoid having to re-prepare and allow for customization.
| |
| prepareForExecution | back to summary |
|---|---|
| public void prepareForExecution() throws QueryException Overrides org. INTERNAL: Prepare the receiver for execution in a session.
| |
| prePrepare | back to summary |
|---|---|
| protected void prePrepare() throws QueryException Overrides org. INTERNAL: Prepare the receiver for execution in a session.
| |
| registerResultInUnitOfWork | back to summary |
|---|---|
| public Object registerResultInUnitOfWork(Object result, UnitOfWorkImpl unitOfWork, AbstractRecord arguments, boolean buildDirectlyFromRows) Implements abstract org. INTERNAL: All objects queried via a UnitOfWork get registered here. If the query went to the database. Involves registering the query result individually and in totality, and hence refreshing / conforming is done here.
| |
| remoteExecute | back to summary |
|---|---|
| protected Object remoteExecute() Overrides org.
| |
| replaceValueHoldersIn | back to summary |
|---|---|
| public Map Overrides org. INTERNAL: replace the value holders in the specified result object(s)
| |
| setSelectionId | back to summary |
|---|---|
| public void setSelectionId(Object id) PUBLIC: The Id of the object to be selected by the query. This will generate a query by primary key. This can be used instead of an Expression, SQL, or JPQL, or example object. The Id is the Id value for a singleton primary key, for a composite it is an instance of CacheId.
| |
| setSelectionObject | back to summary |
|---|---|
| public void setSelectionObject(Object selectionObject) PUBLIC: Used to set the where clause of the query. This can be used instead of a where clause expression for single object primary key queries. The selection object given should have a primary key defined, this primary key will be used to query the database instance of the same object. This is a basic form of query by example where only the primary key is required, it can be used for simple query forms, or testing. | |
| setShouldLoadResultIntoSelectionObject | back to summary |
|---|---|
| public void setShouldLoadResultIntoSelectionObject(boolean shouldLoadResultIntoSelectionObject) PUBLIC: Allow for the selection object of the query to be refreshed or put into the EclipseLink cache. By default on a read or refresh the object in the cache is refreshed and returned or a new object is built from the database, in some cases such as EJB BMP it is desirable to refresh or load into the object passed into the read object query. Note This forces the selection object into the cache a replaces any existing object that may already be there, this is a strict violation of object identity and other objects can still be referring to the old object. | |
| shouldCheckCacheByExactPrimaryKey | back to summary |
|---|---|
| public boolean shouldCheckCacheByExactPrimaryKey() PUBLIC: Return if cache should be checked. | |
| shouldCheckCacheByPrimaryKey | back to summary |
|---|---|
| public boolean shouldCheckCacheByPrimaryKey() PUBLIC: Return if cache should be checked. | |
| shouldCheckCacheThenDatabase | back to summary |
|---|---|
| public boolean shouldCheckCacheThenDatabase() PUBLIC: Return if cache should be checked. | |
| shouldLoadResultIntoSelectionObject | back to summary |
|---|---|
| public boolean shouldLoadResultIntoSelectionObject() PUBLIC: return true if the result should be loaded into the passed in selection Object | |