Interface SimpleProjectionSpecification<T,X>
- Type Parameters:
T- The result type of theSelectionSpecificationX- The type of the projected path or attribute
- All Superinterfaces:
QuerySpecification<T>
Allows a
SelectionSpecification to be augmented with the specification of
a single projected attribute or path.
var specification =
SelectionSpecification.create(Book.class)
.restrict(Restriction.contains(Book_.title, "hibernate", false))
.sort(Order.desc(Book_.title));
var projection = SimpleProjectionSpecification.create(specification, Book_.isbn);
var isbns = projection.createQuery(session).getResultList();
Use of a Path allows joining to associated entities.
var specification =
SelectionSpecification.create(Book.class)
.restrict(Restriction.contains(Book_.title, "hibernate", false))
.sort(Order.desc(Book_.title));
var projection =
SimpleProjectionSpecification.create(specification,
Path.from(Book.class)
.to(Book_.publisher)
.to(Publisher_.name));
var publisherNames = projection.createQuery(session).getResultList();
- Since:
- 7.2
- API Note:
- This interface marked
Incubatingis considered experimental. Changes to the API defined here are fully expected in future releases.
-
Method Summary
Modifier and TypeMethodDescriptionbuildCriteria(CriteriaBuilder builder) Build acriteria querysatisfying this specification, using the givenCriteriaBuilder.static <T,X> SimpleProjectionSpecification <T, X> create(SelectionSpecification<T> selectionSpecification, SingularAttribute<? super T, X> projectedAttribute) Create a newProjectionSpecificationwhich augments the givenSelectionSpecification.static <T,X> SimpleProjectionSpecification <T, X> create(SelectionSpecification<T> selectionSpecification, Path<T, X> projectedPath) Create a newProjectionSpecificationwhich augments the givenSelectionSpecification.createQuery(EntityManager entityManager) Finalize the building and create executable query instance.createQuery(Session session) Finalize the building and create executable query instance.createQuery(StatelessSession session) Finalize the building and create executable query instance.Obtain a reference to this specification which may be passed along toEntityManager.createQuery(TypedQueryReference).validate(CriteriaBuilder builder) Validate the query.Methods inherited from interface QuerySpecification
restrict
-
Method Details
-
create
static <T,X> SimpleProjectionSpecification<T,X> create(SelectionSpecification<T> selectionSpecification, Path<T, X> projectedPath) Create a newProjectionSpecificationwhich augments the givenSelectionSpecification. -
create
static <T,X> SimpleProjectionSpecification<T,X> create(SelectionSpecification<T> selectionSpecification, SingularAttribute<? super T, X> projectedAttribute) Create a newProjectionSpecificationwhich augments the givenSelectionSpecification. -
createQuery
Description copied from interface:QuerySpecificationFinalize the building and create executable query instance.- Specified by:
createQueryin interfaceQuerySpecification<T>
-
createQuery
Description copied from interface:QuerySpecificationFinalize the building and create executable query instance.- Specified by:
createQueryin interfaceQuerySpecification<T>
-
createQuery
Description copied from interface:QuerySpecificationFinalize the building and create executable query instance.- Specified by:
createQueryin interfaceQuerySpecification<T>
-
buildCriteria
Description copied from interface:QuerySpecificationBuild 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>- Returns:
- a new criteria query
-
reference
TypedQueryReference<X> reference()Description copied from interface:QuerySpecificationObtain a reference to this specification which may be passed along toEntityManager.createQuery(TypedQueryReference).- Specified by:
referencein interfaceQuerySpecification<T>
-
validate
Description copied from interface:QuerySpecificationValidate the query.- Specified by:
validatein interfaceQuerySpecification<T>- Returns:
thisif everything is fine
-