Package io.jmix.core
Class SaveContext
java.lang.Object
io.jmix.core.SaveContext
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JpaSaveContext
Defines collections of entities to be saved or removed, as well as parameters of saving.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected List<AccessConstraint<?>>
protected boolean
protected Map<String,
Serializable> protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList<AccessConstraint<?>>
Returns the list of access constraints.Enables defining a fetchPlan for each committed entity.getHints()
boolean
boolean
Adds an entity to be removed from the database.Adds an entity to be committed to the database.Adds an entity to be committed to the database.setAccessConstraints
(List<AccessConstraint<?>> accessConstraints) Sets the list of access constraints.setDiscardSaved
(boolean discardSaved) Set to true if calling code does not need saved instances, which allows for performance optimization.setHint
(String hintName, Serializable value) Sets custom hint that should be used by the query.setHints
(Map<String, Serializable> hints) Sets custom hints that should be used by the query.setJoinTransaction
(boolean joinTransaction) Sets whether to join existing transaction or always start a new one.
-
Field Details
-
entitiesToSave
-
entitiesToRemove
-
fetchPlans
-
discardSaved
protected boolean discardSaved -
joinTransaction
protected boolean joinTransaction -
accessConstraints
-
hints
-
-
Constructor Details
-
SaveContext
public SaveContext()
-
-
Method Details
-
saving
Adds an entity to be committed to the database.This method accepts entity instances and collections.
- Parameters:
entities
- entity instances- Returns:
- this instance for chaining
-
saving
Adds an entity to be committed to the database.- Parameters:
entity
- entity instancefetchPlan
- fetch plan which is used in merge operation to ensure all required attributes are loaded in the returned instance- Returns:
- this instance for chaining
-
removing
Adds an entity to be removed from the database.This method accepts entity instances and collections.
- Parameters:
entities
- entity instances- Returns:
- this instance for chaining
-
getEntitiesToSave
- Returns:
- collection of changed entities that will be saved to the database. The collection is modifiable.
-
getEntitiesToRemove
- Returns:
- collection of entities that will be removed from the database. The collection is modifiable.
-
getFetchPlans
Enables defining a fetchPlan for each committed entity. These fetchPlans are used in merge operation to ensure all required attributes are loaded in returned instances.- Returns:
- mutable map of entities to their fetchPlans
-
getHints
- Returns:
- custom hints which are used by the query
-
setHint
Sets custom hint that should be used by the query. -
setHints
Sets custom hints that should be used by the query. -
isDiscardSaved
public boolean isDiscardSaved()- Returns:
- true if calling code does not need committed instances, which allows for performance optimization
-
setDiscardSaved
Set to true if calling code does not need saved instances, which allows for performance optimization. -
getAccessConstraints
Returns the list of access constraints. -
setAccessConstraints
Sets the list of access constraints. -
isJoinTransaction
public boolean isJoinTransaction()- Returns:
- whether to join existing transaction or always start a new one
-
setJoinTransaction
Sets whether to join existing transaction or always start a new one.
-