Class SelectionSpecificationImpl<T>
java.lang.Object
org.hibernate.query.specification.internal.SelectionSpecificationImpl<T>
- All Implemented Interfaces:
TypedQueryReference<T>,QuerySpecification<T>,SelectionSpecification<T>
public class SelectionSpecificationImpl<T>
extends Object
implements SelectionSpecification<T>, TypedQueryReference<T>
Standard implementation of SelectionSpecification
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.query.specification.SelectionSpecification
SelectionSpecification.Augmentation<T> -
Constructor Summary
ConstructorsConstructorDescriptionSelectionSpecificationImpl(CriteriaQuery<T> criteriaQuery) SelectionSpecificationImpl(Class<T> resultType) SelectionSpecificationImpl(String hql, Class<T> resultType) -
Method Summary
Modifier and TypeMethodDescriptionaugment(SelectionSpecification.Augmentation<T> augmentation) Add an augmentation to the specification.buildCriteria(CriteriaBuilder builder) Build acriteria querysatisfying this specification, using the givenCriteriaBuilder.createQuery(EntityManager entityManager) Finalize the building and create executable query instance.createQuery(Session session) Finalize the building and create executable query instance.createQuery(SharedSessionContract session) createQuery(StatelessSession session) Finalize the building and create executable query instance.Add a fetch path to the specification.getHints()getName()Obtain a reference to this specification which may be passed along toEntityManager.createQuery(TypedQueryReference).final SelectionSpecification<T> Sets the sorting for this selection specification.final SelectionSpecification<T> Sets the ordering for this selection specification.restrict(Restriction<? super T> restriction) Adds a restriction to the query specification.Adds an ordering to the selection specification.validate(CriteriaBuilder builder) Validate the query.
-
Constructor Details
-
SelectionSpecificationImpl
-
SelectionSpecificationImpl
-
SelectionSpecificationImpl
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceTypedQueryReference<T>
-
getResultType
- Specified by:
getResultTypein interfaceTypedQueryReference<T>
-
getHints
- Specified by:
getHintsin interfaceTypedQueryReference<T>
-
reference
Description copied from interface:QuerySpecificationObtain a reference to this specification which may be passed along toEntityManager.createQuery(TypedQueryReference).- Specified by:
referencein interfaceQuerySpecification<T>- Specified by:
referencein interfaceSelectionSpecification<T>
-
restrict
Description copied from interface:QuerySpecificationAdds a restriction to the query specification.- Specified by:
restrictin interfaceQuerySpecification<T>- Specified by:
restrictin interfaceSelectionSpecification<T>- Parameters:
restriction- The restriction predicate to be added.- Returns:
thisfor method chaining.
-
augment
Description copied from interface:SelectionSpecificationAdd an augmentation to the specification.For example:
SelectionSpecification.create(Book.class) .augment((builder, query, book) -> // augment the query via JPA Criteria API query.where(builder.like(book.get(Book_.title), titlePattern)), builder.greaterThan(book.get(Book_.pages), minPages)) .orderBy(builder.asc(book.get(Book_.isbn))) .createQuery(session) .getResultList();For complicated cases, aCriteriaDefinitionmay be used within an augmentation to eliminate repetitive explicit references to theCriteriaBuilder.SelectionSpecification.create(Book.class) .augment((builder, query, book) -> // eliminate explicit references to 'builder' new CriteriaDefinition<>(query) {{ where(like(entity.get(BasicEntity_.title), titlePattern), greaterThan(book.get(Book_.pages), minPages)); orderBy(asc(book.get(Book_.isbn))); }} ) .createQuery(session) .getResultList();- Specified by:
augmentin interfaceSelectionSpecification<T>- Parameters:
augmentation- A function capable of modifying or augmenting a criteria query.- Returns:
thisfor method chaining.
-
fetch
Description copied from interface:SelectionSpecificationAdd a fetch path to the specification.- Specified by:
fetchin interfaceSelectionSpecification<T>- Parameters:
fetchPath- The path to fetch- Returns:
thisfor method chaining.
-
sort
Description copied from interface:SelectionSpecificationAdds an ordering to the selection specification. Appended to any previous ordering.- Specified by:
sortin interfaceSelectionSpecification<T>- Parameters:
order- The ordering fragment to be added.- Returns:
thisfor method chaining.
-
resort
Description copied from interface:SelectionSpecificationSets the ordering for this selection specification. If ordering was already defined, this method drops the previous ordering in favor of the passedorders.- Specified by:
resortin interfaceSelectionSpecification<T>- Parameters:
order- The ordering fragment to be used.- Returns:
thisfor method chaining.
-
resort
Description copied from interface:SelectionSpecificationSets the sorting for this selection specification. If sorting was already defined, this method drops the previous sorting in favor of the passedorders.- Specified by:
resortin interfaceSelectionSpecification<T>- Parameters:
orders- The sorting fragments to be used.- Returns:
thisfor method chaining.
-
createQuery
Description copied from interface:QuerySpecificationFinalize the building and create executable query instance.- Specified by:
createQueryin interfaceQuerySpecification<T>- Specified by:
createQueryin interfaceSelectionSpecification<T>
-
createQuery
Description copied from interface:QuerySpecificationFinalize the building and create executable query instance.- Specified by:
createQueryin interfaceQuerySpecification<T>- Specified by:
createQueryin interfaceSelectionSpecification<T>
-
createQuery
Description copied from interface:QuerySpecificationFinalize the building and create executable query instance.- Specified by:
createQueryin interfaceQuerySpecification<T>- Specified by:
createQueryin interfaceSelectionSpecification<T>
-
buildCriteria
Description copied from interface:SelectionSpecificationBuild acriteria querysatisfying this specification, using the givenCriteriaBuilder.If the returned criteria query is mutated, the mutations will not be not reflected in this specification.
- Specified by:
buildCriteriain interfaceQuerySpecification<T>- Specified by:
buildCriteriain interfaceSelectionSpecification<T>- Returns:
- a new criteria query
-
validate
Description copied from interface:QuerySpecificationValidate the query.- Specified by:
validatein interfaceQuerySpecification<T>- Specified by:
validatein interfaceSelectionSpecification<T>- Returns:
thisif everything is fine
-