Package com.sap.cds.ql
Interface Update<T extends StructuredType<?>>
- Type Parameters:
T
- the type of the entity set targeted by this update statement
- All Superinterfaces:
CqnFilterableStatement
,CqnStatement
,CqnUpdate
,FilterableStatement<T,
,Update<T>> JSONizable
,Statement<Update<T>>
public interface Update<T extends StructuredType<?>>
extends CqnUpdate, FilterableStatement<T,Update<T>>
The Update Builder allows to construct CDS QL update statements, which can be
executed via the
CdsDataStore
.
Note that some methods in this interface 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.-
Method Summary
Modifier and TypeMethodDescriptionSets the where condition of the update statement, requiring that the value of the single key element of the target entity set is equal to the given idValue.Sets the where condition of the update statement.byParams
(Collection<String> elementRefs) Sets the where condition of the update statement.static Update<StructuredType<?>>
static Update<StructuredType<?>>
Creates an update statement to update data for a specified entity set.Adds an element to be updated to the update statement.Sets the values to be updated by the update statement.static Update<StructuredType<?>>
Creates an update statement to update entries of a specified entity set.static Update<StructuredType<?>>
Creates an update statement to update data for a specified entity set.static Update<StructuredType<?>>
entity
(CdsEntity entity, UnaryOperator<StructuredType<?>> path) Creates an update statement to update entries of a specified entity set.static <R extends StructuredType<R>,
T extends StructuredType<T>>
Update<T>Creates an update statement to update data for a specified entity set.static <T extends StructuredType<T>>
Update<T>Creates an update statement to update data for a specified entity set.static Update<StructuredType<?>>
Creates an update statement to update entries of a specified entity set.static Update<StructuredType<?>>
entity
(String qualifiedName, UnaryOperator<StructuredType<?>> path) Creates an update statement to update entries of a specified entity set.static <T extends StructuredType<?>>
Update<T>entity
(T entity) Creates an update statement to update entries from a specified entity set.Sets the batch data to be updated by the update statement.Sets the entry to be updated by the update statement.Sets the where condition of the update statement.Adds an element to be updated to the update statement.set
(Function<T, ElementRef<E>> ref, Function<ElementRef<E>, Value<?>> value) Adds an element to be updated to the update statement.Sets the values to be updated by the update statement.where
(CqnPredicate predicate) Sets the where condition of this update statement to a given predicate.where
(Function<T, CqnPredicate> predicate) Sets the where condition of this update statement.Methods inherited from interface com.sap.cds.ql.cqn.CqnFilterableStatement
where
Methods inherited from interface com.sap.cds.ql.cqn.CqnStatement
asDelete, asInsert, asSelect, asUpsert, hints, isDelete, isInsert, isSelect, isUpsert, ref
Methods inherited from interface com.sap.cds.ql.cqn.CqnUpdate
asUpdate, data, elements, elements, entries, isUpdate, setters
Methods inherited from interface com.sap.cds.JSONizable
toJson
-
Method Details
-
entity
Creates an update statement to update entries of a specified entity set.- Parameters:
qualifiedName
- the fully qualified name of the CDS entity set- Returns:
- the update statement
-
entity
Creates an update statement to update entries of a specified entity set.- Parameters:
ref
- the ref to the entity- Returns:
- the update statement
-
entity
Creates an update statement to update entries from a specified entity set.- Type Parameters:
T
- the type of the entity set- Parameters:
entity
- the structured type representing the entity set- Returns:
- the update statement
-
entity
static Update<StructuredType<?>> entity(String qualifiedName, UnaryOperator<StructuredType<?>> path) Creates an update statement to update entries of a specified entity set.- Parameters:
qualifiedName
- the fully qualified name of the CDS entity setpath
- a path expression navigating from the root entity to the target entity of the update statement- Returns:
- the update statement
-
entity
Creates an update statement to update data for a specified entity set.- Type Parameters:
T
- the type of the entity set- Parameters:
entity
- the static model representation of the entity set- Returns:
- the update statement
-
entity
static <R extends StructuredType<R>,T extends StructuredType<T>> Update<T> entity(Class<R> entity, Function<R, T> path) Creates an update statement to update data for a specified entity set.- Type Parameters:
R
- the type of the root entityT
- the type of the target entity- Parameters:
entity
- the static model representation of the entity setpath
- a path expression navigating from the root entity to the target entity of the update statement- Returns:
- the update statement
-
entity
Creates an update statement to update entries of 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 update statement- Returns:
- the update statement
- See Also:
-
entity
Creates an update statement to update data for a specified entity set.- Parameters:
entity
- the model representation of the entity set obtained by reflection- Returns:
- the update statement
- See Also:
-
copy
- Parameters:
update
- theCqnUpdate
to be copied- Returns:
- the modifiable update statement copy
-
cqn
Creates an update statement to update data for a specified entity set.- Parameters:
model
- the CDS modelcqnUpdate
- the CQN representation of the update statement- Returns:
- the update statement
-
entries
Sets the batch data to be updated by the update statement. The data is given as a collection of maps from element names of the target entity set to their new values. The data must contain the entities' keys.- Parameters:
entries
- a collection of data to be updated given as a map from element name to new value- Returns:
- the update statement
-
entry
Sets the entry to be updated by the update statement. The entry is given as a map of element names of the target entity set to their new values. The entry must contain key value mappings to identify the entity to be updated.- Parameters:
entry
- the data to be updated as a map from element name to new value- Returns:
- the update statement
-
data
Sets the values to be updated by the update statement. The data is given as a map of element names of the target entity set to their new values.- Parameters:
data
- the data to be updated as a map from element name to new value- Returns:
- the update statement
-
data
Adds an element to be updated to the update statement.- Parameters:
elementName
- the element name of the target entityvalue
- the new value of the element- Returns:
- the update statement
- See Also:
-
set
Adds an element to be updated to the update statement. The update value can be aCqnExpression
.- Type Parameters:
E
- the type of the referenced element- Parameters:
ref
- the element ref of the target entityvalue
- the new value of the element- Returns:
- the update statement
-
set
Adds an element to be updated to the update statement. The update value can be aCqnExpression
.- Parameters:
elementName
- the element name of the target entityvalue
- the new value of the element asCqnValue
- Returns:
- the update statement
-
setters
Sets the values to be updated by the update statement. The setters are given as a map of element names of the target entity set to their newCqnValue
, which can be aCqnExpression
.- Parameters:
setters
- the data to be updated as a map from element name to newCqnValue
- Returns:
- the update statement
-
where
Sets the where condition of this update statement to a given predicate. If this update statement already has a where condition it is replaced with the given.- Specified by:
where
in interfaceFilterableStatement<T extends StructuredType<?>,
Update<T extends StructuredType<?>>> - Parameters:
predicate
- aCqnPredicate
- Returns:
- the update statement
-
where
Sets the where condition of this update statement. The where condition is provided as a function that accepts a model object representing the entity targeted by the update and returning the where condition.- Specified by:
where
in interfaceFilterableStatement<T extends StructuredType<?>,
Update<T extends StructuredType<?>>> - Parameters:
predicate
- aFunction
providing the where condition- Returns:
- the update statement
-
matching
Sets the where condition of the update 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.- Specified by:
matching
in interfaceFilterableStatement<T extends StructuredType<?>,
Update<T extends StructuredType<?>>> - Parameters:
values
- the element name to value map defining the where condition- Returns:
- the update statement
-
byParams
Sets the where condition of the update 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.- Specified by:
byParams
in interfaceFilterableStatement<T extends StructuredType<?>,
Update<T extends StructuredType<?>>> - Parameters:
elementRefs
- the element references defining the where condition- Returns:
- this update statement
-
byParams
Sets the where condition of the update 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.- Specified by:
byParams
in interfaceFilterableStatement<T extends StructuredType<?>,
Update<T extends StructuredType<?>>> - Parameters:
elementRefs
- the element references defining the where condition- Returns:
- this update statement
-
byId
Sets the where condition of the update statement, requiring that the value of the single key element of the target entity set is equal to the given idValue.- Specified by:
byId
in interfaceFilterableStatement<T extends StructuredType<?>,
Update<T extends StructuredType<?>>> - Parameters:
idValue
- the value of the target entity's key element- Returns:
- the update statement
-