public class ColumnSelect<T> extends FluentSelect<T,ColumnSelect<T>>
A helper builder for queries selecting individual properties based on the root object.
It can be used to select properties of the object itself, properties of related entities or some function calls (including aggregate functions).
Usage examples:
// select list of names:
List<String> names = ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME).select(context);
// select count:
long count = ObjectSelect.columnQuery(Artist.class, Property.COUNT).selectOne();
// select only required properties of an entity:
List<Object[]> data = ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH)
.where(Artist.ARTIST_NAME.like("Picasso%))
.select(context);
Note: this class can't be instantiated directly. Use ObjectSelect
.
ObjectSelect.columnQuery(Class, Property)
,
Serialized FormcacheGroup, cacheStrategy, dbEntityName, entityName, entityType, limit, offset, orderings, pageSize, prefetches, statementFetchSize, where
dataMap, lastResolver, name, replacementQuery
Modifier | Constructor and Description |
---|---|
protected |
ColumnSelect() |
protected |
ColumnSelect(ObjectSelect<T> select)
Copy constructor to convert ObjectSelect to ColumnSelect
|
Modifier and Type | Method and Description |
---|---|
ColumnSelect<T> |
and(Collection<Expression> expressions)
AND's provided expressions to the existing WHERE or HAVING clause expression.
|
ColumnSelect<Object[]> |
avg(Property<?> property)
Select average value of property
|
protected <E> ColumnSelect<E> |
column(Property<E> property) |
ColumnSelect<Object[]> |
columns(Collection<Property<?>> properties)
Add properties to select.
|
ColumnSelect<Object[]> |
columns(Property<?> firstProperty,
Property<?>... otherProperties)
Add properties to select.
|
ColumnSelect<Object[]> |
count()
Shortcut for
columns(Property, Property[]) columns}(Property.COUNT) |
ColumnSelect<Object[]> |
count(Property<?> property)
Select COUNT(property)
|
protected Query |
createReplacementQuery(EntityResolver resolver)
Translates self to a SelectQuery.
|
Collection<Property<?>> |
getColumns() |
Expression |
getHaving()
Returns a HAVING clause Expression of this query.
|
ColumnSelect<T> |
having(Expression expression)
Appends a having qualifier expression of this query.
|
ColumnSelect<T> |
having(String expressionString,
Object... parameters)
Appends a having qualifier expression of this query, using provided expression
String and an array of position parameters.
|
ColumnSelect<Object[]> |
max(Property<?> property)
Select maximum value of property
|
ColumnSelect<Object[]> |
min(Property<?> property)
Select minimum value of property
|
ColumnSelect<T> |
or(Collection<Expression> expressions)
OR's provided expressions to the existing WHERE or HAVING clause expression.
|
<E extends Number> |
sum(Property<E> property)
Select sum of values
|
and, batchIterator, cacheGroup, cacheStrategy, cacheStrategy, dbEntityName, entityName, entityType, getCacheGroup, getCacheStrategy, getDbEntityName, getEntityName, getEntityType, getLimit, getOffset, getOrderings, getPageSize, getPrefetches, getStatementFetchSize, getWhere, iterate, iterator, limit, localCache, localCache, offset, or, orderBy, orderBy, orderBy, orderBy, pageSize, prefetch, prefetch, select, selectFirst, selectOne, sharedCache, sharedCache, statementFetchSize, where, where
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 ColumnSelect()
protected ColumnSelect(ObjectSelect<T> select)
protected Query createReplacementQuery(EntityResolver resolver)
FluentSelect
createReplacementQuery
in class FluentSelect<T,ColumnSelect<T>>
public ColumnSelect<Object[]> columns(Property<?> firstProperty, Property<?>... otherProperties)
Add properties to select.
Can be any properties that can be resolved against root entity type (root entity properties, function call expressions, properties of relationships, etc).
List<Object[]> columns = ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME)
.columns(Artist.ARTIST_SALARY, Artist.DATE_OF_BIRTH)
.select(context);
firstProperty
- first propertyotherProperties
- array of properties to selectcolumn(Property)
,
columns(Collection)
public ColumnSelect<Object[]> columns(Collection<Property<?>> properties)
Add properties to select.
Can be any properties that can be resolved against root entity type (root entity properties, function call expressions, properties of relationships, etc).
properties
- collection of properties, must contain at least one elementcolumns(Property, Property[])
protected <E> ColumnSelect<E> column(Property<E> property)
public ColumnSelect<Object[]> count()
Shortcut for columns(Property, Property[])
columns}(Property.COUNT)
public ColumnSelect<Object[]> count(Property<?> property)
Select COUNT(property)
Can return different result than COUNT(*) as it will count only non null values
count()
public ColumnSelect<Object[]> min(Property<?> property)
Select minimum value of property
columns(Property, Property[])
public ColumnSelect<Object[]> max(Property<?> property)
Select maximum value of property
columns(Property, Property[])
public ColumnSelect<Object[]> avg(Property<?> property)
Select average value of property
columns(Property, Property[])
public <E extends Number> ColumnSelect<Object[]> sum(Property<E> property)
Select sum of values
columns(Property, Property[])
public ColumnSelect<T> having(Expression expression)
FluentSelect.and(Expression...)
that can be used a syntactic sugar.public ColumnSelect<T> having(String expressionString, Object... parameters)
public ColumnSelect<T> and(Collection<Expression> expressions)
and
in class FluentSelect<T,ColumnSelect<T>>
public ColumnSelect<T> or(Collection<Expression> expressions)
or
in class FluentSelect<T,ColumnSelect<T>>
public Collection<Property<?>> getColumns()
public Expression getHaving()
Copyright © 2001–2017 Apache Cayenne. All rights reserved.