public class CQuery<T> extends Object implements DbReadContext, CancelableQuery
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 and Description |
|---|
CQuery(OrmQueryRequest<T> request,
CQueryPredicates predicates,
CQueryPlan queryPlan)
Create the Sql select based on the request.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel the query.
|
void |
close()
Close the resources.
|
BeanCollection<T> |
continueFetchingInBackground() |
javax.persistence.PersistenceException |
createPersistenceException(SQLException e)
Create a PersistenceException including interesting information like the
bindLog and sql used.
|
static javax.persistence.PersistenceException |
createPersistenceException(SQLException e,
SpiTransaction t,
String bindLog,
String sql)
Create a PersistenceException including interesting information like the
bindLog and sql used.
|
String |
getBeanName()
Return the short bean name.
|
String |
getBeanType() |
String |
getBindLog() |
DataReader |
getDataReader()
Return the DataReader.
|
String |
getGeneratedSql()
Return the generated sql.
|
LoadContext |
getGraphContext() |
T |
getLoadedBean()
Return the last read bean.
|
String |
getLoadedRowDetail() |
String |
getLogWhereSql()
Return the where predicate for display in the transaction log.
|
BeanPropertyAssocMany<?> |
getManyProperty()
Return the property that is associated with the many.
|
String |
getName()
Return the query name.
|
PersistenceContext |
getPersistenceContext()
Return the persistence context.
|
CQueryPredicates |
getPredicates() |
long |
getQueryExecutionTimeMicros() |
SpiQuery.Mode |
getQueryMode()
Return the query mode.
|
SpiOrmQueryRequest<?> |
getQueryRequest() |
SqlTree |
getSqlTree()
Return the SqlSelectChain.
|
String |
getSummary()
Get the summary of the sql.
|
SpiTransaction |
getTransaction() |
protected boolean |
hasNextBean(boolean inForeground) |
boolean |
isAutoFetchProfiling()
Should we create profileNodes for beans created in this 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.
|
boolean |
prepareBindExecuteQuery()
Prepare bind and execute the query normally.
|
boolean |
prepareBindExecuteQueryForwardOnly(boolean dbPlatformForwardOnlyHint)
Prepare bind and execute query with Forward only hints.
|
void |
profileBean(EntityBeanIntercept ebi,
String prefix)
Add autoFetch profiling for a loaded entity bean.
|
void |
propagateState(Object e)
Propagate the state to the bean.
|
boolean |
readBean() |
BeanCollection<T> |
readCollection() |
QueryIterator<T> |
readIterate(int bufferSize,
OrmQueryRequest<T> request) |
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 |
setCurrentPrefix(String currentPrefix,
Map<String,String> currentPathMap)
Set the JoinNode - used by proxy/reference beans for profiling.
|
void |
setLoadedBean(Object bean,
Object id,
Object lazyLoadParentId)
Set back the bean that has just been loaded with its id.
|
void |
setLoadedManyBean(Object manyValue)
Set back the 'detail' bean that has just been loaded.
|
protected void |
updateExecutionStatistics() |
boolean |
useBackgroundToContinueFetch() |
public CQuery(OrmQueryRequest<T> request, CQueryPredicates predicates, CQueryPlan queryPlan)
public Boolean isReadOnly()
DbReadContextisReadOnly in interface DbReadContextpublic void propagateState(Object e)
DbReadContextpropagateState in interface DbReadContextpublic DataReader getDataReader()
DbReadContextgetDataReader in interface DbReadContextpublic SpiQuery.Mode getQueryMode()
DbReadContextgetQueryMode in interface DbReadContextpublic CQueryPredicates getPredicates()
public LoadContext getGraphContext()
public SpiOrmQueryRequest<?> getQueryRequest()
public void cancel()
CancelableQueryFor JDBC this translates to calling cancel on the PreparedStatement.
cancel in interface CancelableQuerypublic boolean prepareBindExecuteQueryForwardOnly(boolean dbPlatformForwardOnlyHint)
throws SQLException
SQLExceptionpublic boolean prepareBindExecuteQuery()
throws SQLException
SQLExceptionpublic void close()
The jdbc resultSet and statement need to be closed. Its important that this method is called.
public PersistenceContext getPersistenceContext()
getPersistenceContext in interface DbReadContextpublic void setLoadedBean(Object bean, Object id, Object lazyLoadParentId)
DbReadContextsetLoadedBean in interface DbReadContextpublic void setLoadedManyBean(Object manyValue)
DbReadContextsetLoadedManyBean in interface DbReadContextpublic T getLoadedBean()
public long getQueryExecutionTimeMicros()
public boolean readBean()
throws SQLException
SQLExceptionpublic BeanCollection<T> continueFetchingInBackground() throws SQLException
SQLExceptionpublic BeanCollection<T> readCollection() throws SQLException
SQLExceptionprotected void updateExecutionStatistics()
public QueryIterator<T> readIterate(int bufferSize, OrmQueryRequest<T> request)
protected boolean hasNextBean(boolean inForeground)
throws SQLException
SQLExceptionpublic String getLoadedRowDetail()
public void register(String path, EntityBeanIntercept ebi)
DbReadContextregister in interface DbReadContextpublic void register(String path, BeanCollection<?> bc)
DbReadContextregister in interface DbReadContextpublic boolean useBackgroundToContinueFetch()
public String getName()
public boolean isRawSql()
isRawSql in interface DbReadContextpublic String getLogWhereSql()
public BeanPropertyAssocMany<?> getManyProperty()
getManyProperty in interface DbReadContextpublic String getSummary()
public SqlTree getSqlTree()
public String getBindLog()
public SpiTransaction getTransaction()
public String getBeanType()
public String getBeanName()
public String getGeneratedSql()
public javax.persistence.PersistenceException createPersistenceException(SQLException e)
public static javax.persistence.PersistenceException createPersistenceException(SQLException e, SpiTransaction t, String bindLog, String sql)
public boolean isAutoFetchProfiling()
This is true for all queries except lazy load bean queries.
isAutoFetchProfiling in interface DbReadContextpublic void profileBean(EntityBeanIntercept ebi, String prefix)
DbReadContextprofileBean in interface DbReadContextpublic void setCurrentPrefix(String currentPrefix, Map<String,String> currentPathMap)
DbReadContextsetCurrentPrefix in interface DbReadContextCopyright © 2014. All Rights Reserved.