T
- the type of the entity set that is the source of this select
statementpublic abstract class Select<T extends StructuredType<?>> extends StatementBuilder<Select<T>> implements Source<T>, CqnSelect, FilterableStatement<T,Select<T>>
CdsDataStore
.
Note that some methods in this class mutually exclude each other and cannot
be combined. For example, the methods byId
,
byParams
, matching
, and
where
all set the where condition of the
enclosing statement, overwriting any previously stored conditions.hints
Constructor and Description |
---|
Select() |
Modifier and Type | Method and Description |
---|---|
void |
accept(CqnVisitor visitor)
Traverses the expression tree represented by this token with a given
visitor . |
abstract Select<T> |
byId(Object idValue)
Sets the where condition of the select statement, requiring that the value of
the single key element of the target entity set is equal to the given
idValue.
|
abstract Select<T> |
byParams(Collection<String> elementRefs)
Sets the where condition of the select statement.
|
Select<T> |
byParams(String... elementRefs)
Sets the where condition of the select statement.
|
Select<T> |
columns(Function<T,? extends Selectable>... items)
Sets the projection of the select statement.
|
abstract Select<T> |
columns(List<? extends Selectable> items)
Sets the projection of the select statement.
|
Select<T> |
columns(Selectable... items)
Sets the projection of the select statement.
|
abstract Select<T> |
columns(Stream<? extends Selectable> items)
Sets the projection of the select statement.
|
abstract Select<T> |
columns(String... elements)
Sets the projection of the select statement.
|
static Select<StructuredType<?>> |
copy(CqnSelect select)
|
static Select<StructuredType<?>> |
cqn(String cqnSelect)
Creates a select statement from a given CQN String.
|
abstract Select<T> |
distinct()
Specifies that duplicate query results should be eliminated.
|
abstract Select<T> |
excluding(Collection<String> qualifiedNames)
Sets the exclude list of the select statement.
|
Select<T> |
excluding(Function<T,CqnSelectListValue>... items)
Sets the exclude list of the select statement.
|
Select<T> |
excluding(String... qualifiedNames)
Sets the exclude list of the select statement.
|
static Select<StructuredType<?>> |
from(CdsEntity entity)
Creates a select statement to select entries from a specified entity set.
|
static Select<StructuredType<?>> |
from(CdsEntity entity,
UnaryOperator<StructuredType<?>> path)
Creates a select statement to select entries from a specified entity set.
|
static <R extends StructuredType<R>,T extends StructuredType<T>> |
from(Class<R> entity,
Function<R,T> path)
Creates a select statement to select entries from a specified entity set.
|
static <T extends StructuredType<T>> |
from(Class<T> entity)
Creates a select statement to select entries from a specified entity set.
|
static Select<StructuredType<?>> |
from(CqnSelect subquery)
Creates a select statement to select entries from the result of a given
subquery.
|
static Select<StructuredType<?>> |
from(CqnStructuredTypeRef ref)
Creates a select statement to select entries from a specified entity set.
|
static Select<StructuredType<?>> |
from(String qualifiedName)
Creates a select statement to select entries from a specified entity set.
|
static Select<StructuredType<?>> |
from(String entityName,
UnaryOperator<StructuredType<?>> path)
Creates a select statement to select entries from a specified entity set.
|
static <T extends StructuredType<T>> |
from(StructuredType<T> entity)
Creates a select statement to select entries from a specified entity set.
|
abstract Select<T> |
groupBy(Collection<CqnSelectListItem> dimensions)
Deprecated.
use
groupBy(List) instead |
Select<T> |
groupBy(CqnValue... dimensions)
Sets the group by clause of the select statement.
|
Select<T> |
groupBy(Function<T,CqnValue>... dimensions)
Sets the group by clause of the select statement.
|
abstract Select<T> |
groupBy(List<? extends CqnValue> dimensions)
Sets the group by clause of the select statement.
|
abstract Select<T> |
groupBy(Stream<? extends CqnValue> dimensions)
Sets the group by clause of the select statement.
|
abstract Select<T> |
groupBy(String... elements)
Sets the groupBy clause of the select statement.
|
abstract Select<T> |
having(CqnPredicate pred)
Sets the having clause of the select statement.
|
abstract Select<T> |
having(Function<T,CqnPredicate> pred)
Sets the having clause of the select statement.
|
abstract Select<T> |
inlineCount()
Specifies that the total number of root entities matching this query shall be
returned along with the result.
|
Select<T> |
limit(long top)
Sets the limit of the select statement.
|
abstract Select<T> |
limit(long top,
long skip)
Sets the limit and offset of the select statement.
|
Select<T> |
lock()
Creates a write lock on the selected rows for a default number of seconds
specified by DB so that other queries cannot lock or change the data until
current transaction is finished.
|
abstract Select<T> |
lock(CqnLock.Mode mode)
Creates a write lock on the selected rows for a default number of seconds
specified by DB so that other queries cannot lock or change the data until
current transaction is finished.
|
abstract Select<T> |
lock(CqnLock.Mode mode,
int timeout)
Creates a write lock on the selected rows so that other queries cannot lock
or change the data until current transaction is finished.
|
Select<T> |
lock(int timeout)
Creates a write lock on the selected rows so that other queries cannot lock
or change the data until current transaction is finished.
|
abstract Select<T> |
matching(Map<String,?> values)
Sets the where condition of the select statement.
|
Select<T> |
orderBy(CqnSortSpecification... sortSpecs)
Sets the orderBy clause of the select statement.
|
Select<T> |
orderBy(Function<T,CqnSortSpecification>... sortSpecs)
Sets the orderBy clause of the select statement.
|
abstract Select<T> |
orderBy(List<CqnSortSpecification> sortSpecs)
Sets the orderBy clause of the select statement.
|
abstract Select<T> |
orderBy(String... elements)
Sets the orderBy clause of the select statement.
|
abstract Select<T> |
search(CqnPredicate pred)
Adds a search filter to this select statement, requiring that any searchable
element of the target entity set matches the given search predicate.
|
abstract Select<T> |
search(Function<Searchable,Predicate> pred)
Adds a search filter to this select statement, requiring that any searchable
element of the target entity set matches the given search predicate.
|
abstract Select<T> |
search(Function<Searchable,Predicate> pred,
Iterable<String> searchableElements)
Adds a search filter to this select statement, requiring that any searchable
element of the target entity set matches the given search predicate.
|
abstract Select<T> |
search(String searchTerm)
Adds a search filter to this select statement, requiring that any searchable
element of the target entity set matches the given search term
|
abstract Select<T> |
search(String searchTerm,
Iterable<String> searchableElements)
Adds a search filter to this select statement, requiring that any given
searchable element of the target entity set matches the given search term.
|
String |
toString() |
abstract Select<T> |
where(CqnPredicate pred)
Sets the where condition of this select statement to a given predicate.
|
abstract Select<T> |
where(Function<T,CqnPredicate> pred)
Sets the where condition of this select statement.
|
hint, hints, hints, hints
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asSelect, columns, dispatch, excluding, from, getLock, groupBy, hasInlineCount, having, isDistinct, isSelect, search
hasLimit, items, limit, orderBy, ref, skip, top
asJoin, asQuery, asRef, isJoin, isQuery, isRef
where
asDelete, asInsert, asUpdate, asUpsert, hints, isDelete, isInsert, isUpdate, isUpsert, ref
toJson
public static Select<StructuredType<?>> from(String qualifiedName)
qualifiedName
- the fully qualified name of the CDS entity setpublic static Select<StructuredType<?>> from(CqnStructuredTypeRef ref)
ref
- the ref to the entity to select entries frompublic static <T extends StructuredType<T>> Select<T> from(StructuredType<T> entity)
T
- the type of the entity setentity
- the structured type representing the entity setpublic static Select<StructuredType<?>> from(String entityName, UnaryOperator<StructuredType<?>> path)
entityName
- the root entity name of the path expressionpath
- a path expression navigating from the root entity to the
target entity of the select statementpublic static Select<StructuredType<?>> from(CdsEntity entity)
entity
- the model representation of the entity set obtained by
reflectionCdsModel.findEntity(String)
,
CdsModel.entities()
public static Select<StructuredType<?>> from(CqnSelect subquery)
subquery
- the subquery to select frompublic static Select<StructuredType<?>> from(CdsEntity entity, UnaryOperator<StructuredType<?>> path)
entity
- the model representation of the entity set obtained by
reflectionpath
- a path expression navigating from the root entity to the target
entity of the select statementCdsModel.findEntity(String)
,
CdsModel.entities()
public static <T extends StructuredType<T>> Select<T> from(Class<T> entity)
T
- the type of the entity setentity
- the static model representation of the entity setpublic static <R extends StructuredType<R>,T extends StructuredType<T>> Select<T> from(Class<R> entity, Function<R,T> path)
R
- the type of the root entityT
- the type of the target entityentity
- the static model representation of the entity setpath
- a path expression navigating from the root entity to the target
entity of the select statementpublic static Select<StructuredType<?>> copy(CqnSelect select)
select
- the CqnSelect
to be copiedpublic static Select<StructuredType<?>> cqn(String cqnSelect)
cqnSelect
- the CQN representation of the select statementpublic abstract Select<T> distinct()
public abstract Select<T> inlineCount()
@SafeVarargs public final Select<T> columns(Selectable... items)
items
- the CqnSelectListItem(s)
that shall be
selected@SafeVarargs public final Select<T> columns(Function<T,? extends Selectable>... items)
items
- Function(s)
providing the
CqnSelectListItem(s)
that shall be
selectedpublic abstract Select<T> columns(List<? extends Selectable> items)
items
- the CqnSelectListItem(s)
that shall be
selectedpublic abstract Select<T> columns(Stream<? extends Selectable> items)
items
- the CqnSelectListItem(s)
that shall be
selectedpublic abstract Select<T> columns(String... elements)
elements
- the element(s) that shall be selectedpublic final Select<T> excluding(String... qualifiedNames)
qualifiedNames
- the items that shall be excluded from the projection@SafeVarargs public final Select<T> excluding(Function<T,CqnSelectListValue>... items)
items
- Function(s)
providing the
CqnSelectListValue(s)
that shall be
excluded from the projectionpublic abstract Select<T> excluding(Collection<String> qualifiedNames)
qualifiedNames
- the items that shall be excluded from the projectionpublic abstract Select<T> where(Function<T,CqnPredicate> pred)
where
in interface FilterableStatement<T extends StructuredType<?>,Select<T extends StructuredType<?>>>
pred
- a Function
providing the where conditionpublic abstract Select<T> where(CqnPredicate pred)
where
in interface FilterableStatement<T extends StructuredType<?>,Select<T extends StructuredType<?>>>
pred
- the CqnPredicate
public abstract Select<T> matching(Map<String,?> values)
CqnParameter
. The map entries are transformed into
equality predicates and joined via and.matching
in interface FilterableStatement<T extends StructuredType<?>,Select<T extends StructuredType<?>>>
values
- the element name to value map defining the where conditionpublic Select<T> byParams(String... elementRefs)
CqnParameter
that has the name of the ref. The predicates are
joined via and.byParams
in interface FilterableStatement<T extends StructuredType<?>,Select<T extends StructuredType<?>>>
elementRefs
- the element references defining the where conditionpublic abstract Select<T> byParams(Collection<String> elementRefs)
CqnParameter
that has the name of the ref. The predicates are joined
via and.byParams
in interface FilterableStatement<T extends StructuredType<?>,Select<T extends StructuredType<?>>>
elementRefs
- the element references defining the where conditionpublic abstract Select<T> byId(Object idValue)
byId
in interface FilterableStatement<T extends StructuredType<?>,Select<T extends StructuredType<?>>>
idValue
- the value of the target entity's key elementpublic abstract Select<T> search(String searchTerm)
searchTerm
- the value to be searched forpublic abstract Select<T> search(Function<Searchable,Predicate> pred)
pred
- search predicatepublic abstract Select<T> search(CqnPredicate pred)
pred
- search predicatepublic abstract Select<T> search(Function<Searchable,Predicate> pred, Iterable<String> searchableElements)
pred
- search predicatesearchableElements
- elements to be searched in. Overwrites default
searchable columns.public abstract Select<T> search(String searchTerm, Iterable<String> searchableElements)
searchTerm
- the value to be searched forsearchableElements
- elements to be searched in. Overwrites default
searchable columns.public abstract Select<T> lock(CqnLock.Mode mode, int timeout)
mode
- the lock modetimeout
- maximum number of seconds to wait for [timeout] seconds for
the lock acquisition, afterwards the query will fail with the
CdsLockTimeoutException
CdsLockTimeoutException
- if a lock could not be acquiredpublic abstract Select<T> lock(CqnLock.Mode mode)
CdsLockTimeoutException
is thrown.mode
- the lock modeCdsLockTimeoutException
- if a lock could not be acquiredpublic Select<T> lock(int timeout)
timeout
- maximum number of seconds to wait for [timeout] seconds for
the lock acquisition, afterwards the query will fail with the
CdsLockTimeoutException
CdsLockTimeoutException
- if a lock could not be acquiredpublic Select<T> lock()
CdsLockTimeoutException
is thrown.CdsLockTimeoutException
- if a lock could not be acquiredpublic final Select<T> groupBy(CqnValue... dimensions)
dimensions
- the elements the select shall be grouped by@SafeVarargs public final Select<T> groupBy(Function<T,CqnValue>... dimensions)
dimensions
- Function(s)
providing the CqnValue(s)
the select shall be grouped bypublic abstract Select<T> groupBy(List<? extends CqnValue> dimensions)
dimensions
- the CqnValue(s)
the select shall be
grouped bypublic abstract Select<T> groupBy(Stream<? extends CqnValue> dimensions)
dimensions
- the CqnValue(s)
the select shall be
grouped by@Deprecated public abstract Select<T> groupBy(Collection<CqnSelectListItem> dimensions)
groupBy(List)
insteadpublic abstract Select<T> groupBy(String... elements)
elements
- the element(s) the select shall be grouped bypublic abstract Select<T> having(CqnPredicate pred)
pred
- the having predicate conditionpublic abstract Select<T> having(Function<T,CqnPredicate> pred)
pred
- Function(s)
providing the having predicate
condition@SafeVarargs public final Select<T> orderBy(Function<T,CqnSortSpecification>... sortSpecs)
sortSpecs
- Function(s)
providing the sort
specificationpublic final Select<T> orderBy(CqnSortSpecification... sortSpecs)
sortSpecs
- the sort specificationspublic abstract Select<T> orderBy(List<CqnSortSpecification> sortSpecs)
sortSpecs
- the sort specificationspublic abstract Select<T> orderBy(String... elements)
elements
- the elements defining the sort orderpublic Select<T> limit(long top)
top
- the maximum number of rows returned by the query or -1 if
unlimitedpublic abstract Select<T> limit(long top, long skip)
top
- the maximum number of rows returned by the query or -1 if
unlimitedskip
- the number of rows that shall be skippedpublic String toString()
toString
in class StatementBuilder<Select<T extends StructuredType<?>>>
public void accept(CqnVisitor visitor)
CqnToken
visitor
. The traversal order is depth-first. If this token has
child nodes they are traversed first by dispatching the visitor to the
children's accept
methods.
Afterwards this token is passed to the visitor's visit
method
specific for this token's type.accept
in interface CqnSelect
accept
in interface CqnToken
visitor
- the CqnVisitor
Copyright © 2023 SAP. All rights reserved.