Interface UpdateSpecification<T>
- Type Parameters:
T
- The entity type which is the target of the mutation.
- All Superinterfaces:
MutationSpecification<T>
,QuerySpecification<T>
Specialization of
MutationSpecification
for programmatic customization
of update queries.
The method assign(Assignment)
allows application of additional
assignments to the mutated entity. The static factory
methods of Assignment
are used to express assignments to attributes
or compound paths.
UpdateSpecification.create(Book.class) .assign(Assignment.set(Book_.title, newTitle)) .restrict(Restriction.equal(Book_.isbn, isbn)) .createQuery(session) .executeUpdate();
- Since:
- 7.2
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.query.specification.MutationSpecification
MutationSpecification.Augmentation<T>
-
Method Summary
Modifier and TypeMethodDescriptionassign
(Assignment<? super T> assignment) Add an assigment to a field or property of the target entity.augment
(MutationSpecification.Augmentation<T> augmentation) Add an augmentation to the specification.static <T> UpdateSpecification
<T> create
(CriteriaUpdate<T> criteriaUpdate) Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery based on the given criteria update, allowing the addition of restrictions and assignments.static <T> UpdateSpecification
<T> Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery which updates the given entity type.reassign
(List<? extends Assignment<? super T>> assignments) Sets the assignments to fields or properties of the target entity.restrict
(Restriction<? super T> restriction) Adds a restriction to the query specification.validate
(CriteriaBuilder builder) Validate the query.Methods inherited from interface org.hibernate.query.specification.MutationSpecification
createQuery, createQuery, reference
Methods inherited from interface org.hibernate.query.specification.QuerySpecification
buildCriteria, createQuery
-
Method Details
-
assign
Add an assigment to a field or property of the target entity.- Parameters:
assignment
- The assignment to add- Returns:
this
for method chaining.
-
reassign
Sets the assignments to fields or properties of the target entity. If assignments were already specified, this method drops the previous assignments in favor of the passedassignments
.- Parameters:
assignments
- The new assignments- Returns:
this
for method chaining.
-
restrict
Description copied from interface:QuerySpecification
Adds a restriction to the query specification.- Specified by:
restrict
in interfaceMutationSpecification<T>
- Specified by:
restrict
in interfaceQuerySpecification<T>
- Parameters:
restriction
- The restriction predicate to be added.- Returns:
this
for method chaining.
-
augment
Description copied from interface:MutationSpecification
Add an augmentation to the specification.- Specified by:
augment
in interfaceMutationSpecification<T>
- Parameters:
augmentation
- A function capable of modifying or augmenting a criteria query.- Returns:
this
for method chaining.
-
validate
Description copied from interface:QuerySpecification
Validate the query.- Specified by:
validate
in interfaceMutationSpecification<T>
- Specified by:
validate
in interfaceQuerySpecification<T>
- Returns:
this
if everything is fine
-
create
Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery which updates the given entity type.- Type Parameters:
T
- The root entity type for the mutation (the "target").- Parameters:
targetEntityClass
- The target entity type
-
create
Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery based on the given criteria update, allowing the addition of restrictions and assignments.- Type Parameters:
T
- The root entity type for the mutation (the "target").- Parameters:
criteriaUpdate
- The criteria update query
-