public abstract class FluentSelect<T,S extends FluentSelect<T,S>> extends IndirectQuery implements Select<T>
ObjectSelect
and ColumnSelect
Modifier and Type | Field and Description |
---|---|
protected String |
cacheGroup |
protected QueryCacheStrategy |
cacheStrategy |
protected String |
dbEntityName |
protected String |
entityName |
protected Class<?> |
entityType |
protected int |
limit |
protected int |
offset |
protected Collection<Ordering> |
orderings |
protected int |
pageSize |
protected PrefetchTreeNode |
prefetches |
protected int |
statementFetchSize |
protected Expression |
where |
dataMap, lastResolver, name, replacementQuery
Modifier | Constructor and Description |
---|---|
protected |
FluentSelect() |
Modifier and Type | Method and Description |
---|---|
S |
and(Collection<Expression> expressions)
AND's provided expressions to the existing WHERE clause expression.
|
S |
and(Expression... expressions)
AND's provided expressions to the existing WHERE clause expression.
|
ResultBatchIterator<T> |
batchIterator(ObjectContext context,
int size)
Creates a ResultBatchIterator based on the provided context and batch
size.
|
S |
cacheGroup(String cacheGroup) |
S |
cacheStrategy(QueryCacheStrategy strategy) |
S |
cacheStrategy(QueryCacheStrategy strategy,
String cacheGroup) |
protected Query |
createReplacementQuery(EntityResolver resolver)
Translates self to a SelectQuery.
|
S |
dbEntityName(String dbEntityName)
Sets the
DbEntity name to fetch without changing the return type
of the query. |
S |
entityName(String entityName)
Sets the
ObjEntity name to fetch without changing the return type
of the query. |
S |
entityType(Class<?> entityType)
Sets the type of the entity to fetch without changing the return type of
the query.
|
String |
getCacheGroup() |
QueryCacheStrategy |
getCacheStrategy() |
String |
getDbEntityName() |
String |
getEntityName() |
Class<?> |
getEntityType() |
int |
getLimit() |
int |
getOffset() |
Collection<Ordering> |
getOrderings() |
int |
getPageSize() |
PrefetchTreeNode |
getPrefetches() |
int |
getStatementFetchSize() |
Expression |
getWhere()
Returns a WHERE clause Expression of this query.
|
void |
iterate(ObjectContext context,
ResultIteratorCallback<T> callback)
Creates a ResultIterator based on the provided context and passes it to a
callback for processing.
|
ResultIterator<T> |
iterator(ObjectContext context)
Creates a ResultIterator based on the provided context.
|
S |
limit(int fetchLimit)
Resets query fetch limit - a parameter that defines max number of objects
that should be ever be fetched from the database.
|
S |
localCache()
Instructs Cayenne to look for query results in the "local" cache when
running the query.
|
S |
localCache(String cacheGroup)
Instructs Cayenne to look for query results in the "local" cache when
running the query.
|
S |
offset(int fetchOffset)
Resets query fetch offset - a parameter that defines how many objects
should be skipped when reading data from the database.
|
S |
or(Collection<Expression> expressions)
OR's provided expressions to the existing WHERE clause expression.
|
S |
or(Expression... expressions)
OR's provided expressions to the existing WHERE clause expression.
|
S |
orderBy(Collection<Ordering> orderings)
Adds a list of orderings to this query.
|
S |
orderBy(Ordering... orderings)
Add one or more orderings to this query.
|
S |
orderBy(String property)
Add an ascending ordering on the given property.
|
S |
orderBy(String property,
SortOrder sortOrder)
Add an ordering on the given property.
|
S |
pageSize(int pageSize)
Resets query page size.
|
S |
prefetch(PrefetchTreeNode prefetch)
Merges prefetch into the query prefetch tree.
|
S |
prefetch(String path,
int semantics)
Merges a prefetch path with specified semantics into the query prefetch
tree.
|
List<T> |
select(ObjectContext context)
Selects objects using provided context.
|
T |
selectFirst(ObjectContext context)
Selects a single object using provided context.
|
T |
selectOne(ObjectContext context)
Selects a single object using provided context.
|
S |
sharedCache()
Instructs Cayenne to look for query results in the "shared" cache when
running the query.
|
S |
sharedCache(String cacheGroup)
Instructs Cayenne to look for query results in the "shared" cache when
running the query.
|
S |
statementFetchSize(int size)
Sets fetch size of the PreparedStatement generated for this query.
|
S |
where(Expression expression)
Appends a qualifier expression of this query.
|
S |
where(String expressionString,
Object... parameters)
Appends a qualifier expression of this query, using provided expression
String and an array of position parameters.
|
createSQLAction, getDataMap, getMetaData, getName, getReplacementQuery, route, setDataMap, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createSQLAction, getDataMap, getMetaData, getName, route
protected Class<?> entityType
protected String entityName
protected String dbEntityName
protected Expression where
protected Collection<Ordering> orderings
protected PrefetchTreeNode prefetches
protected int limit
protected int offset
protected int pageSize
protected int statementFetchSize
protected QueryCacheStrategy cacheStrategy
protected String cacheGroup
protected Query createReplacementQuery(EntityResolver resolver)
createReplacementQuery
in class IndirectQuery
public S entityType(Class<?> entityType)
public S entityName(String entityName)
ObjEntity
name to fetch without changing the return type
of the query. This form is most often used for generic entities that
don't map to a distinct class.public S dbEntityName(String dbEntityName)
DbEntity
name to fetch without changing the return type
of the query. This form is most often used for generic entities that
don't map to a distinct class.public S where(Expression expression)
and(Expression...)
that can be used a syntactic sugar.public S where(String expressionString, Object... parameters)
public S and(Expression... expressions)
public S and(Collection<Expression> expressions)
public S or(Expression... expressions)
public S or(Collection<Expression> expressions)
public S orderBy(String property)
property
- the property to sort onpublic S orderBy(String property, SortOrder sortOrder)
property
- the property to sort onsortOrder
- the direction of the orderingpublic S orderBy(Ordering... orderings)
public S orderBy(Collection<Ordering> orderings)
public S prefetch(PrefetchTreeNode prefetch)
public S prefetch(String path, int semantics)
public S limit(int fetchLimit)
public S offset(int fetchOffset)
public S pageSize(int pageSize)
public S statementFetchSize(int size)
Statement.setFetchSize(int)
public S cacheStrategy(QueryCacheStrategy strategy)
public S cacheStrategy(QueryCacheStrategy strategy, String cacheGroup)
public S localCache(String cacheGroup)
query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, cacheGroup);
public S localCache()
query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
public S sharedCache(String cacheGroup)
query.cacheStrategy(QueryCacheStrategy.SHARED_CACHE, cacheGroup);
public S sharedCache()
query.cacheStrategy(QueryCacheStrategy.SHARED_CACHE);
public String getCacheGroup()
public QueryCacheStrategy getCacheStrategy()
public int getStatementFetchSize()
public int getPageSize()
public int getLimit()
public int getOffset()
public Class<?> getEntityType()
public String getEntityName()
public String getDbEntityName()
public Expression getWhere()
public Collection<Ordering> getOrderings()
public PrefetchTreeNode getPrefetches()
public List<T> select(ObjectContext context)
Select
Essentially the inversion of "ObjectContext.select(Select)".
public T selectOne(ObjectContext context)
Select
CayenneRuntimeException
is thrown.
Essentially the inversion of "ObjectContext.selectOne(Select)".
public T selectFirst(ObjectContext context)
Select
If it matched more than one object, the first object from the list is
returned. This makes 'selectFirst' different from
Select.selectOne(ObjectContext)
, which would throw in this situation.
'selectFirst' is useful e.g. when the query is ordered and we only want
to see the first object (e.g. "most recent news article"), etc.
Selecting the first object via "Select.selectFirst(ObjectContext)" is more comprehensible than selecting via "ObjectContext.selectFirst(Select)", because implementations of "Select" set fetch size limit to one.
selectFirst
in interface Select<T>
public void iterate(ObjectContext context, ResultIteratorCallback<T> callback)
Select
Essentially the inversion of "ObjectContext.iterate(Select, ResultIteratorCallback)".
public ResultIterator<T> iterator(ObjectContext context)
Select
Select.iterate(ObjectContext, ResultIteratorCallback)
as an
alternative.
Essentially the inversion of "ObjectContext.iterator(Select)".
public ResultBatchIterator<T> batchIterator(ObjectContext context, int size)
Select
batchIterator
in interface Select<T>
Copyright © 2001–2017 Apache Cayenne. All rights reserved.