Package com.sap.cds.ql
Interface Upsert
-
- All Superinterfaces:
CqnStatement
,CqnUpsert
,CqnXsert
,JSONizable
,Statement<Upsert>
public interface Upsert extends CqnUpsert, Statement<Upsert>
The Upsert builder allows to construct a CDS QL Upsert statements, which can be executed via theCdsDataStore
. An Upsert statement updates an entity from the given data. The key of the entity that is upserted is expected to be in the data. If the entity doesn't exist and the key is given in the data, it inserts a new entry.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.sap.cds.ql.cqn.CqnXsert
CqnXsert.Kind
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Upsert
copy(CqnUpsert upsert)
static Upsert
cqn(String cqnUpsert)
Creates an upsert statement to upsert data for a specified entity set.Upsert
entries(Iterable<? extends Map<String,?>> entries)
Sets the batch data to be inserted or updated by the upsert statement.Upsert
entry(String elementName, Object value)
Adds a single entry to be upserted into the entity set.Upsert
entry(Map<String,?> entry)
Adds a single entry to be upserted into the entity set.static Upsert
into(CqnStructuredTypeRef ref)
Creates an upsert statement to upsert entries into a specified entity set.static Upsert
into(CdsEntity entity)
Creates an upsert statement to upsert entries into a specified entity set.static Upsert
into(CdsEntity entity, UnaryOperator<StructuredType<?>> path)
Creates an upsert statement to upsert entries into a specified entity set.static <R extends StructuredType<R>,T extends StructuredType<T>>
Upsertinto(Class<R> entity, Function<R,T> path)
Creates an upsert statement to upsert entries into a specified entity set.static <T extends StructuredType<T>>
Upsertinto(Class<T> entity)
Creates an upsert statement to upsert entries into a specified entity set.static Upsert
into(String qualifiedName)
Creates an upsert statement to upsert entries into a specified entity set.static Upsert
into(String qualifiedName, UnaryOperator<StructuredType<?>> path)
Creates an upsert statement to upsert entries into a specified entity set.static <T extends StructuredType<?>>
Upsertinto(T entity)
Creates an upsert statement to upsert entries into a specified entity set.-
Methods inherited from interface com.sap.cds.ql.cqn.CqnStatement
asDelete, asInsert, asSelect, asUpdate, hints, isDelete, isInsert, isSelect, isUpdate, ref
-
Methods inherited from interface com.sap.cds.JSONizable
toJson
-
-
-
-
Method Detail
-
into
static Upsert into(String qualifiedName)
Creates an upsert statement to upsert entries into a specified entity set.- Parameters:
qualifiedName
- the fully qualified name of the CDS entity set- Returns:
- the upsert statement
-
into
static Upsert into(CqnStructuredTypeRef ref)
Creates an upsert statement to upsert entries into a specified entity set.- Parameters:
ref
- the ref to the entity- Returns:
- the upsert statement
-
into
static <T extends StructuredType<?>> Upsert into(T entity)
Creates an upsert statement to upsert entries into a specified entity set.- Type Parameters:
T
- the type of the entity set- Parameters:
entity
- the structured type representing the entity set- Returns:
- the upsert statement
-
into
static Upsert into(String qualifiedName, UnaryOperator<StructuredType<?>> path)
Creates an upsert statement to upsert entries into 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 upsert statement- Returns:
- the upsert statement
-
into
static <T extends StructuredType<T>> Upsert into(Class<T> entity)
Creates an upsert statement to upsert entries into 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 upsert statement
-
into
static <R extends StructuredType<R>,T extends StructuredType<T>> Upsert into(Class<R> entity, Function<R,T> path)
Creates an upsert statement to upsert entries into 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 upsert statement- Returns:
- the upsert statement
-
into
static Upsert into(CdsEntity entity)
Creates an upsert statement to upsert entries into a specified entity set.- Parameters:
entity
- the model representation of the entity set obtained by reflection- Returns:
- the upsert statement
- See Also:
CdsModel.findEntity(String)
,CdsModel.entities()
-
into
static Upsert into(CdsEntity entity, UnaryOperator<StructuredType<?>> path)
Creates an upsert statement to upsert entries into 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 upsert statement- Returns:
- the upsert statement
- See Also:
CdsModel.findEntity(String)
,CdsModel.entities()
-
copy
static Upsert copy(CqnUpsert upsert)
- Parameters:
upsert
- theCqnUpsert
to be copied- Returns:
- the modifiable upsert statement copy
-
cqn
static Upsert cqn(String cqnUpsert)
Creates an upsert statement to upsert data for a specified entity set.- Parameters:
cqnUpsert
- the CQN representation of the upsert statement- Returns:
- the upsert statement
-
entries
Upsert entries(Iterable<? extends Map<String,?>> entries)
Sets the batch data to be inserted or updated by the upsert 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 where every element is the canonical representation- Returns:
- the upsert statement
-
entry
Upsert entry(Map<String,?> entry)
Adds a single entry to be upserted into the entity set. The data is given as a Map<String, Object> that maps element names of the target entity set to the values to be upserted.The value can be deeply structured to represent a structured document:
- for single-valued relationships the value of the element is of type Map<String, Object>
- for collection-valued relationships the value of the element is of type List<Map<String, Object>>
- Parameters:
entry
- the data to be upserted as a map- Returns:
- the upsert statement
-
entry
Upsert entry(String elementName, Object value)
Adds a single entry to be upserted into the entity set.The value can be deeply structured to represent a structured document:
- for single-valued relationships the value of the element is of type Map<String, Object>
- for collection-valued relationships the value of the element is of type List<Map<String, Object>>
- Parameters:
elementName
- the element name of the target entity for the value to be upsertedvalue
- the data to be upserted for the element- Returns:
- the upsert statement
-
-