Package com.sap.cds.ql
Interface Delete<T extends StructuredType<?>>
-
- Type Parameters:
T
- the type of the entity set targeted by this delete statement
- All Superinterfaces:
CqnDelete
,CqnStatement
,JSONizable
,Statement<Delete<T>>
public interface Delete<T extends StructuredType<?>> extends CqnDelete, Statement<Delete<T>>
The Delete Builder allows to construct CDS QL delete statements, which can be executed via theCdsDataStore
. Note that some methods in this interface mutually exclude each other and cannot be combined. For example, the methodsbyId
,byParams
,matching
, andwhere
all set the where condition of the enclosing statement, overwriting any previously stored conditions.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Delete<T>
byId(Object idValue)
Sets the where condition of the delete statement, requiring that the value of the single key element of the target entity set is equal to the given idValue.default Delete<T>
byParams(String... elementRefs)
Sets the where condition of the delete statement.Delete<T>
byParams(Collection<String> elementRefs)
Sets the where condition of the delete statement.static Delete<StructuredType<?>>
copy(CqnDelete delete)
static Delete<StructuredType<?>>
cqn(String cqnDelete)
Creates a delete statement to delete entries from a specified entity set.static Delete<StructuredType<?>>
from(CqnStructuredTypeRef ref)
Creates a delete statement to delete entries from a specified entity set.static Delete<StructuredType<?>>
from(CdsEntity entity)
Creates a delete statement to delete entries from a specified entity set.static Delete<StructuredType<?>>
from(CdsEntity entity, UnaryOperator<StructuredType<?>> path)
Creates a delete statement to delete entries from a specified entity set.static <E extends StructuredType<?>>
Delete<E>from(E entity)
Creates a delete statement to delete entries from a specified entity set.static <E extends StructuredType<E>>
Delete<E>from(Class<E> entity)
Creates a delete statement to delete entries from a specified entity set.static <E extends StructuredType<E>,R extends StructuredType<R>>
Delete<R>from(Class<E> entity, Function<E,R> path)
Creates a delete statement to delete entries from a specified entity set.static Delete<StructuredType<?>>
from(String qualifiedName)
Creates a delete statement to delete entries from a specified entity set.static Delete<StructuredType<?>>
from(String rootEntityName, UnaryOperator<StructuredType<?>> path)
Creates a delete statement to delete entries from a specified entity set.Delete<T>
matching(Map<String,?> values)
Sets the where condition of the delete statement.Delete<T>
where(CqnPredicate predicate)
Sets the where condition of the delete statement.Delete<T>
where(Function<T,CqnPredicate> predicate)
Sets the where condition of the delete statement.-
Methods inherited from interface com.sap.cds.ql.cqn.CqnStatement
asInsert, asSelect, asUpdate, asUpsert, hints, isInsert, isSelect, isUpdate, isUpsert, ref
-
Methods inherited from interface com.sap.cds.JSONizable
toJson
-
-
-
-
Method Detail
-
from
static Delete<StructuredType<?>> from(String qualifiedName)
Creates a delete statement to delete entries from a specified entity set.- Parameters:
qualifiedName
- the fully qualified name of the CDS entity set- Returns:
- the delete statement
-
from
static Delete<StructuredType<?>> from(CqnStructuredTypeRef ref)
Creates a delete statement to delete entries from a specified entity set.- Parameters:
ref
- the ref to the entity- Returns:
- the delete statement
-
from
static <E extends StructuredType<?>> Delete<E> from(E entity)
Creates a delete statement to delete entries from a specified entity set.- Type Parameters:
E
- the type of the entity set- Parameters:
entity
- the structured type representing the entity set- Returns:
- the delete statement
-
from
static Delete<StructuredType<?>> from(String rootEntityName, UnaryOperator<StructuredType<?>> path)
Creates a delete statement to delete entries from a specified entity set.- Parameters:
rootEntityName
- the fully qualified name of the CDS entity setpath
- a path expression navigating from the root entity to the target entity of the delete statement- Returns:
- the delete statement
-
from
static <E extends StructuredType<E>> Delete<E> from(Class<E> entity)
Creates a delete statement to delete entries from a specified entity set.- Type Parameters:
E
- the type of root entity- Parameters:
entity
- the static model representation of the entity set- Returns:
- the delete statement
-
from
static <E extends StructuredType<E>,R extends StructuredType<R>> Delete<R> from(Class<E> entity, Function<E,R> path)
Creates a delete statement to delete entries from a specified entity set.- Type Parameters:
E
- the type of root entityR
- the type of entity to be returned from path expression- Parameters:
entity
- the static model representation of the entity setpath
- a path expression navigating from the root entity to the target entity of the delete statement- Returns:
- the delete statement
-
from
static Delete<StructuredType<?>> from(CdsEntity entity)
Creates a delete statement to delete entries from a specified entity set.- Parameters:
entity
- the model representation of the entity set obtained by reflection- Returns:
- the delete statement
- See Also:
CdsModel.findEntity(String)
,CdsModel.entities()
-
from
static Delete<StructuredType<?>> from(CdsEntity entity, UnaryOperator<StructuredType<?>> path)
Creates a delete statement to delete entries from a specified entity set.- Parameters:
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 delete statement- Returns:
- the delete statement
- See Also:
CdsModel.findEntity(String)
,CdsModel.entities()
-
copy
static Delete<StructuredType<?>> copy(CqnDelete delete)
- Parameters:
delete
- theCqnDelete
to be copied- Returns:
- the modifiable delete statement copy
-
cqn
static Delete<StructuredType<?>> cqn(String cqnDelete)
Creates a delete statement to delete entries from a specified entity set.- Parameters:
cqnDelete
- the CQN representation of delete statement- Returns:
- the delete statement
-
where
Delete<T> where(CqnPredicate predicate)
Sets the where condition of the delete statement.- Parameters:
predicate
- aCqnPredicate
- Returns:
- the delete statement
-
where
Delete<T> where(Function<T,CqnPredicate> predicate)
Sets the where condition of the delete statement. The where condition is provided as a function that accepts a model object representing the entity targeted by the delete and returning the where condition.- Parameters:
predicate
- aFunction
providing the where condition- Returns:
- the delete statement
-
matching
Delete<T> matching(Map<String,?> values)
Sets the where condition of the delete statement. The where condition is computed from a map of element names of the target entity set to their values, or aCqnParameter
. The map entries are transformed into comparison predicates and joined via and.- Parameters:
values
- the element name to value map defining the where condition- Returns:
- the delete statement
-
byParams
default Delete<T> byParams(String... elementRefs)
Sets the where condition of the delete statement. The where condition is computed from the given vararg of element references of the target entity. For each element reference a predicate is created comparing the element ref with aCqnParameter
that has the name of the ref. The predicates are joined via and.- Parameters:
elementRefs
- the element references defining the where condition- Returns:
- this delete statement
-
byParams
Delete<T> byParams(Collection<String> elementRefs)
Sets the where condition of the delete statement. The where condition is computed from the given collection of element references of the target entity. For each element ref a predicate is created comparing the ref with aCqnParameter
that has the name of the ref. The predicates are joined via and.- Parameters:
elementRefs
- the element references defining the where condition- Returns:
- this delete statement
-
-