Interface MutationSpecification<T>
- Type Parameters:
T- The entity type which is the target of the mutation.
- All Superinterfaces:
QuerySpecification<T>
- All Known Implementing Classes:
MutationSpecificationImpl
Specialization of
QuerySpecification for programmatic customization of
mutation queries.
The method restrict(Restriction) allows application of additional
filtering to the mutated entity. The static factory
methods of Restriction are used to express filtering criteria of various
kinds.
MutationSpecification.create(Book.class, "delete from Book")
.restrict(Restriction.lessThan(Book_.publicationDate,
LocalDate.ofYearDay(2000,1)))
.createQuery(session)
.executeUpdate();
Once all restrictions are specified, call
createQuery() to obtain an executable mutation query object.
- Since:
- 7.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA function capable of modifying or augmenting a criteria query. -
Method Summary
Modifier and TypeMethodDescriptionaugment(MutationSpecification.Augmentation<T> augmentation) Add an augmentation to the specification.static <T> MutationSpecification<T>create(CriteriaDelete<T> criteriaDelete) Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery based on the given criteria delete, allowing the addition of restrictions.static <T> MutationSpecification<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.static <T> MutationSpecification<T>Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery based on a base HQL statement, allowing the addition of restrictions.createQuery(Session session) Finalize the building and create the MutationQuery instance.createQuery(StatelessSession session) Finalize the building and create the MutationQuery instance.Obtain a reference to this specification which may be passed along toEntityManager.createQuery(TypedQueryReference).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.QuerySpecification
buildCriteria, createQuery
-
Method Details
-
restrict
Description copied from interface:QuerySpecificationAdds a restriction to the query specification.- Specified by:
restrictin interfaceQuerySpecification<T>- Parameters:
restriction- The restriction predicate to be added.- Returns:
thisfor method chaining.
-
augment
Add an augmentation to the specification.- Parameters:
augmentation- A function capable of modifying or augmenting a criteria query.- Returns:
thisfor method chaining.
-
createQuery
Finalize the building and create the MutationQuery instance.- Specified by:
createQueryin interfaceQuerySpecification<T>
-
createQuery
Finalize the building and create the MutationQuery instance.- Specified by:
createQueryin interfaceQuerySpecification<T>
-
validate
Description copied from interface:QuerySpecificationValidate the query.- Specified by:
validatein interfaceQuerySpecification<T>- Returns:
thisif everything is fine
-
reference
TypedQueryReference<Void> reference()Description copied from interface:QuerySpecificationObtain a reference to this specification which may be passed along toEntityManager.createQuery(TypedQueryReference).- Specified by:
referencein interfaceQuerySpecification<T>
-
create
Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery based on a base HQL statement, allowing the addition of restrictions.- Type Parameters:
T- The root entity type for the mutation (the "target").mutationTargetand<T>are both expected to refer to the mutation target.- Parameters:
hql- The base HQL query (expected to be anupdateordeletequery).mutationTarget- The entity which is the target of the mutation.- Throws:
IllegalMutationQueryException- Onlyupdateanddeleteare supported; this method will throw an exception if the given HQL query is not anupdateordelete.
-
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.- Type Parameters:
T- The root entity type for the mutation (the "target").- Parameters:
criteriaUpdate- The criteria update query
-
create
Returns a specification reference which can be used to programmatically, iteratively build a MutationQuery based on the given criteria delete, allowing the addition of restrictions.- Type Parameters:
T- The root entity type for the mutation (the "target").- Parameters:
criteriaDelete- The criteria delete query
-