public class ObjectSelect<T> extends FluentSelect<T,ObjectSelect<T>>
SelectQuery
when you want to use a fluent API. For example, the following
is a convenient way to return a record:
Artist a = ObjectSelect
.query(Artist.class)
.where(Artist.NAME.eq("Picasso"))
.selectOne(context);
Modifier and Type | Field and Description |
---|---|
protected boolean |
fetchingDataRows |
cacheGroup, cacheStrategy, dbEntityName, entityName, entityType, limit, offset, orderings, pageSize, prefetches, statementFetchSize, where
dataMap, lastResolver, name, replacementQuery
Modifier | Constructor and Description |
---|---|
protected |
ObjectSelect() |
Modifier and Type | Method and Description |
---|---|
<E> ColumnSelect<E> |
avg(Property<E> property)
Select average value of property
|
<E> ColumnSelect<E> |
column(Property<E> property)
Select one specific property.
|
protected static ColumnSelect<Object[]> |
columnQuery(Class<?> entityType,
Property<?> firstColumn,
Property<?>... otherColumns)
Creates a ColumnSelect that will fetch multiple columns of a given
ObjEntity |
protected static <E> ColumnSelect<E> |
columnQuery(Class<?> entityType,
Property<E> column)
Creates a ColumnSelect that will fetch single property that can be resolved
against a given
ObjEntity class. |
ColumnSelect<Object[]> |
columns(Property<?> firstProperty,
Property<?>... properties)
Select only specific properties.
|
ColumnSelect<Long> |
count()
Select COUNT(*)
|
ColumnSelect<Long> |
count(Property<?> property)
Select COUNT(property)
|
protected Query |
createReplacementQuery(EntityResolver resolver)
Translates self to a SelectQuery.
|
static ObjectSelect<DataRow> |
dataRowQuery(Class<?> entityType)
Creates a ObjectSelect that fetches data for an
ObjEntity
determined from a provided class. |
static ObjectSelect<DataRow> |
dataRowQuery(Class<?> entityType,
Expression expression)
Creates a ObjectSelect that fetches data for an
ObjEntity
determined from a provided class and uses provided expression for its
qualifier. |
static ObjectSelect<DataRow> |
dbQuery(String dbEntityName)
Creates a ObjectSelect that fetches DataRows for a
DbEntity
determined from provided "dbEntityName". |
static ObjectSelect<DataRow> |
dbQuery(String dbEntityName,
Expression expression)
Creates a ObjectSelect that fetches DataRows for a
DbEntity
determined from provided "dbEntityName" and uses provided expression for
its qualifier. |
ObjectSelect<DataRow> |
fetchDataRows()
Forces query to fetch DataRows.
|
boolean |
isFetchingDataRows() |
<E> ColumnSelect<E> |
max(Property<E> property)
Select maximum value of property
|
<E> ColumnSelect<E> |
min(Property<E> property)
Select minimum value of property
|
static <T> ObjectSelect<T> |
query(Class<T> entityType)
Creates a ObjectSelect that selects objects of a given persistent class.
|
static <T> ObjectSelect<T> |
query(Class<T> entityType,
Expression expression)
Creates a ObjectSelect that selects objects of a given persistent class
and uses provided expression for its qualifier.
|
static <T> ObjectSelect<T> |
query(Class<T> entityType,
Expression expression,
List<Ordering> orderings)
Creates a ObjectSelect that selects objects of a given persistent class
and uses provided expression for its qualifier.
|
static <T> ObjectSelect<T> |
query(Class<T> resultType,
String entityName)
Creates a ObjectSelect that fetches data for
ObjEntity determined
from provided "entityName", but fetches the result of a provided type. |
long |
selectCount(ObjectContext context)
Quick way to select count of records
|
<E extends Number> |
sum(Property<E> property)
Select sum of values
|
and, 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, 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
public static <T> ObjectSelect<T> query(Class<T> entityType)
public static <T> ObjectSelect<T> query(Class<T> entityType, Expression expression)
public static <T> ObjectSelect<T> query(Class<T> entityType, Expression expression, List<Ordering> orderings)
public static ObjectSelect<DataRow> dataRowQuery(Class<?> entityType)
ObjEntity
determined from a provided class.public static ObjectSelect<DataRow> dataRowQuery(Class<?> entityType, Expression expression)
ObjEntity
determined from a provided class and uses provided expression for its
qualifier.public static <T> ObjectSelect<T> query(Class<T> resultType, String entityName)
ObjEntity
determined
from provided "entityName", but fetches the result of a provided type.
This factory method is most often used with generic classes that by
themselves are not enough to resolve the entity to fetch.public static ObjectSelect<DataRow> dbQuery(String dbEntityName)
DbEntity
determined from provided "dbEntityName".public static ObjectSelect<DataRow> dbQuery(String dbEntityName, Expression expression)
DbEntity
determined from provided "dbEntityName" and uses provided expression for
its qualifier.protected static <E> ColumnSelect<E> columnQuery(Class<?> entityType, Property<E> column)
ObjEntity
class.entityType
- base persistent class that will be used as a root for this querycolumn
- single column to selectprotected static ColumnSelect<Object[]> columnQuery(Class<?> entityType, Property<?> firstColumn, Property<?>... otherColumns)
ObjEntity
entityType
- base persistent class that will be used as a root for this queryfirstColumn
- column to selectotherColumns
- columns to selectprotected Query createReplacementQuery(EntityResolver resolver)
createReplacementQuery
in class FluentSelect<T,ObjectSelect<T>>
public ObjectSelect<DataRow> fetchDataRows()
public ColumnSelect<Object[]> columns(Property<?> firstProperty, Property<?>... properties)
Select only specific properties.
Can be any properties that can be resolved against root entity type (root entity's properties, function call expressions, properties of relationships, etc).
List<Object[]> columns = ObjectSelect.query(Artist.class)
.columns(Artist.ARTIST_NAME, Artist.DATE_OF_BIRTH)
.select(context);
properties
- array of properties to selectcolumn(Property)
public <E> ColumnSelect<E> column(Property<E> property)
Select one specific property.
Can be any property that can be resolved against root entity type (root entity's property, function call expression, property of relationships, etc)
If you need several columns use columns(Property, Property[])
method.
List<String> names = ObjectSelect.query(Artist.class)
.column(Artist.ARTIST_NAME)
.select(context);
property
- single property to selectcolumns(Property, Property[])
public ColumnSelect<Long> count()
column(Property)
public ColumnSelect<Long> count(Property<?> property)
Select COUNT(property)
Can return different result than COUNT(*) as it will count only non null values
count()
,
column(Property)
public <E> ColumnSelect<E> min(Property<E> property)
Select minimum value of property
column(Property)
public <E> ColumnSelect<E> max(Property<E> property)
Select maximum value of property
column(Property)
public <E> ColumnSelect<E> avg(Property<E> property)
Select average value of property
column(Property)
public <E extends Number> ColumnSelect<E> sum(Property<E> property)
Select sum of values
column(Property)
public long selectCount(ObjectContext context)
Quick way to select count of records
Usage:
long count = ObjectSelect.query(Artist.class)
.where(Artist.ARTIST_NAME.like("a%"))
.selectCount(context);
context
- to perform querypublic boolean isFetchingDataRows()
Copyright © 2001–2017 Apache Cayenne. All rights reserved.