Package io.ebeaninternal.server.query
Class CQuery<T>
- java.lang.Object
-
- io.ebeaninternal.server.query.CQuery<T>
-
- All Implemented Interfaces:
SpiProfileTransactionEvent
,DbReadContext
,CancelableQuery
public class CQuery<T> extends Object implements DbReadContext, CancelableQuery, SpiProfileTransactionEvent
An object that represents a SqlSelect statement.The SqlSelect is based on a tree (Object Graph). The tree is traversed to see what parts are included in the tree according to the value of find.getInclude();
The tree structure is flattened into a SqlSelectChain. The SqlSelectChain is the key object used in reading the flat resultSet back into Objects.
-
-
Constructor Summary
Constructors Constructor Description CQuery(OrmQueryRequest<T> request, CQueryPredicates predicates, CQueryPlan queryPlan)
Create the Sql select based on the request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancel the query.void
close()
Close the resources.String
getBindLog()
DataReader
getDataReader()
Return the DataReader.Set<String>
getDependentTables()
String
getGeneratedSql()
Return the generated sql.STreePropertyAssocMany
getManyProperty()
Return the property that is associated with the many.PersistenceContext
getPersistenceContext()
Return the persistence context.CQueryPredicates
getPredicates()
SpiQuery.Mode
getQueryMode()
Return the query mode.SpiTransaction
getTransaction()
void
handleLoadError(String fullName, Exception e)
Handles a load error on given property.boolean
isAutoTuneProfiling()
Should we create profileNodes for beans created in this query.boolean
isDisableLazyLoading()
Return true if this request disables lazy loading.boolean
isDraftQuery()
Return true if the underlying query is a 'asDraft' query.boolean
isRawSql()
Return true if this is a raw sql query as opposed to Ebean generated sql.Boolean
isReadOnly()
Return the state of the object graph.void
profile()
Add the event information to the profiling transaction.void
profileBean(EntityBeanIntercept ebi, String prefix)
Add AutoTune profiling for a loaded entity bean.void
propagateState(Object e)
Propagate the state to the bean.void
register(String path, BeanCollection<?> bc)
Register a collection for lazy loading.void
register(String path, EntityBeanIntercept ebi)
Register a reference for lazy loading.void
registerBeanInherit(BeanPropertyAssocOne<?> property, EntityBeanIntercept ebi)
Register a reference with inheritance for lazy loading.void
setCurrentPrefix(String currentPrefix, Map<String,String> currentPathMap)
Set the JoinNode - used by proxy/reference beans for profiling.void
setLazyLoadedChildBean(EntityBean bean, Object lazyLoadParentId)
Set back the bean that has just been loaded with its id.
-
-
-
Constructor Detail
-
CQuery
public CQuery(OrmQueryRequest<T> request, CQueryPredicates predicates, CQueryPlan queryPlan)
Create the Sql select based on the request.
-
-
Method Detail
-
isDraftQuery
public boolean isDraftQuery()
Description copied from interface:DbReadContext
Return true if the underlying query is a 'asDraft' query.- Specified by:
isDraftQuery
in interfaceDbReadContext
-
isDisableLazyLoading
public boolean isDisableLazyLoading()
Description copied from interface:DbReadContext
Return true if this request disables lazy loading.- Specified by:
isDisableLazyLoading
in interfaceDbReadContext
-
isReadOnly
public Boolean isReadOnly()
Description copied from interface:DbReadContext
Return the state of the object graph.- Specified by:
isReadOnly
in interfaceDbReadContext
-
propagateState
public void propagateState(Object e)
Description copied from interface:DbReadContext
Propagate the state to the bean.- Specified by:
propagateState
in interfaceDbReadContext
-
getDataReader
public DataReader getDataReader()
Description copied from interface:DbReadContext
Return the DataReader.- Specified by:
getDataReader
in interfaceDbReadContext
-
getQueryMode
public SpiQuery.Mode getQueryMode()
Description copied from interface:DbReadContext
Return the query mode.- Specified by:
getQueryMode
in interfaceDbReadContext
-
getPredicates
public CQueryPredicates getPredicates()
-
cancel
public void cancel()
Description copied from interface:CancelableQuery
Cancel the query.For JDBC this translates to calling cancel on the PreparedStatement.
- Specified by:
cancel
in interfaceCancelableQuery
-
close
public void close()
Close the resources.The JDBC resultSet and statement need to be closed. Its important that this method is called.
-
getPersistenceContext
public PersistenceContext getPersistenceContext()
Return the persistence context.- Specified by:
getPersistenceContext
in interfaceDbReadContext
-
setLazyLoadedChildBean
public void setLazyLoadedChildBean(EntityBean bean, Object lazyLoadParentId)
Description copied from interface:DbReadContext
Set back the bean that has just been loaded with its id.- Specified by:
setLazyLoadedChildBean
in interfaceDbReadContext
-
profile
public void profile()
Description copied from interface:SpiProfileTransactionEvent
Add the event information to the profiling transaction.- Specified by:
profile
in interfaceSpiProfileTransactionEvent
-
registerBeanInherit
public void registerBeanInherit(BeanPropertyAssocOne<?> property, EntityBeanIntercept ebi)
Description copied from interface:DbReadContext
Register a reference with inheritance for lazy loading.- Specified by:
registerBeanInherit
in interfaceDbReadContext
-
register
public void register(String path, EntityBeanIntercept ebi)
Description copied from interface:DbReadContext
Register a reference for lazy loading.- Specified by:
register
in interfaceDbReadContext
-
register
public void register(String path, BeanCollection<?> bc)
Description copied from interface:DbReadContext
Register a collection for lazy loading.- Specified by:
register
in interfaceDbReadContext
-
isRawSql
public boolean isRawSql()
Return true if this is a raw sql query as opposed to Ebean generated sql.- Specified by:
isRawSql
in interfaceDbReadContext
-
getManyProperty
public STreePropertyAssocMany getManyProperty()
Return the property that is associated with the many. There can only be one per SqlSelect. This can be null.- Specified by:
getManyProperty
in interfaceDbReadContext
-
getBindLog
public String getBindLog()
-
getTransaction
public SpiTransaction getTransaction()
-
getGeneratedSql
public String getGeneratedSql()
Return the generated sql.
-
isAutoTuneProfiling
public boolean isAutoTuneProfiling()
Should we create profileNodes for beans created in this query.This is true for all queries except lazy load bean queries.
- Specified by:
isAutoTuneProfiling
in interfaceDbReadContext
-
profileBean
public void profileBean(EntityBeanIntercept ebi, String prefix)
Description copied from interface:DbReadContext
Add AutoTune profiling for a loaded entity bean.- Specified by:
profileBean
in interfaceDbReadContext
-
setCurrentPrefix
public void setCurrentPrefix(String currentPrefix, Map<String,String> currentPathMap)
Description copied from interface:DbReadContext
Set the JoinNode - used by proxy/reference beans for profiling.- Specified by:
setCurrentPrefix
in interfaceDbReadContext
-
handleLoadError
public void handleLoadError(String fullName, Exception e)
Description copied from interface:DbReadContext
Handles a load error on given property.- Specified by:
handleLoadError
in interfaceDbReadContext
-
getDependentTables
public Set<String> getDependentTables()
-
-