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 Details

    • entity

      static Update<StructuredType<?>> entity(String qualifiedName)
      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

      static Update<StructuredType<?>> entity(CqnStructuredTypeRef ref)
      Creates an update statement to update entries of a specified entity set.
      Parameters:
      ref - the ref to the entity
      Returns:
      the update statement
    • entity

      static <T extends StructuredType<?>> Update<T> entity(T 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 set
      path - a path expression navigating from the root entity to the target entity of the update statement
      Returns:
      the update statement
    • entity

      static <T extends StructuredType<T>> Update<T> entity(Class<T> 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 entity
      T - the type of the target entity
      Parameters:
      entity - the static model representation of the entity set
      path - a path expression navigating from the root entity to the target entity of the update statement
      Returns:
      the update statement
    • entity

      static Update<StructuredType<?>> entity(CdsEntity entity, UnaryOperator<StructuredType<?>> path)
      Creates an update statement to update entries of a specified entity set.
      Parameters:
      entity - the model representation of the entity set obtained by reflection
      path - a path expression navigating from the root entity to the target entity of the update statement
      Returns:
      the update statement
      See Also:
    • entity

      static Update<StructuredType<?>> entity(CdsEntity 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

      static Update<StructuredType<?>> copy(CqnUpdate update)
      Copies the given CqnUpdate into an Update builder.
      Parameters:
      update - the CqnUpdate to be copied
      Returns:
      the modifiable update statement copy
    • cqn

      @Deprecated(since="2.6.0", forRemoval=true) static Update<StructuredType<?>> cqn(String cqnUpdate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates an update statement to update data for a specified entity set.
      Parameters:
      cqnUpdate - the CQN representation of the update statement
      Returns:
      the update statement
    • cqn

      static Update<StructuredType<?>> cqn(CdsModel model, String cqnUpdate)
      Creates an update statement to update data for a specified entity set.
      Parameters:
      model - the CDS model
      cqnUpdate - the CQN representation of the update statement
      Returns:
      the update statement
    • entries

      Update<T> entries(Iterable<? extends Map<String,?>> 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

      Update<T> entry(Map<String,?> 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

      Update<T> data(Map<String,?> 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

      Update<T> data(String elementName, Object value)
      Adds an element to be updated to the update statement.
      Parameters:
      elementName - the element name of the target entity
      value - the new value of the element
      Returns:
      the update statement
      See Also:
    • set

      <E> Update<T> set(Function<T,ElementRef<E>> ref, Function<ElementRef<E>,Value<?>> value)
      Adds an element to be updated to the update statement. The update value can be a CqnExpression.
      Type Parameters:
      E - the type of the referenced element
      Parameters:
      ref - the element ref of the target entity
      value - the new value of the element
      Returns:
      the update statement
    • set

      Update<T> set(String elementName, CqnValue value)
      Adds an element to be updated to the update statement. The update value can be a CqnExpression.
      Parameters:
      elementName - the element name of the target entity
      value - the new value of the element as CqnValue
      Returns:
      the update statement
    • setters

      Update<T> setters(Map<String,CqnValue> 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 new CqnValue, which can be a CqnExpression.
      Parameters:
      setters - the data to be updated as a map from element name to new CqnValue
      Returns:
      the update statement
    • where

      Update<T> where(CqnPredicate predicate)
      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 interface FilterableStatement<T extends StructuredType<?>,Update<T extends StructuredType<?>>>
      Parameters:
      predicate - a CqnPredicate
      Returns:
      the update statement
    • where

      Update<T> where(Function<T,CqnPredicate> predicate)
      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 interface FilterableStatement<T extends StructuredType<?>,Update<T extends StructuredType<?>>>
      Parameters:
      predicate - a Function providing the where condition
      Returns:
      the update statement
    • matching

      Update<T> matching(Map<String,?> values)
      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 a CqnParameter. The map entries are transformed into comparison predicates and joined via and.
      Specified by:
      matching in interface FilterableStatement<T extends StructuredType<?>,Update<T extends StructuredType<?>>>
      Parameters:
      values - the element name to value map defining the where condition
      Returns:
      the update statement
    • byParams

      Update<T> byParams(String... elementRefs)
      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 a CqnParameter that has the name of the ref. The predicates are joined via and.
      Specified by:
      byParams in interface FilterableStatement<T extends StructuredType<?>,Update<T extends StructuredType<?>>>
      Parameters:
      elementRefs - the element references defining the where condition
      Returns:
      this update statement
    • byParams

      Update<T> byParams(Collection<String> elementRefs)
      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 a CqnParameter that has the name of the ref. The predicates are joined via and.
      Specified by:
      byParams in interface FilterableStatement<T extends StructuredType<?>,Update<T extends StructuredType<?>>>
      Parameters:
      elementRefs - the element references defining the where condition
      Returns:
      this update statement
    • byId

      Update<T> byId(Object idValue)
      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 interface FilterableStatement<T extends StructuredType<?>,Update<T extends StructuredType<?>>>
      Parameters:
      idValue - the value of the target entity's key element
      Returns:
      the update statement