Interface ProjectionSpecification<T>

Type Parameters:
T - The result type of the SelectionSpecification
All Superinterfaces:
QuerySpecification<Object[]>

@Incubating public interface ProjectionSpecification<T> extends QuerySpecification<Object[]>
Allows a SelectionSpecification to be augmented with the specification of a projection list.
 var specification =
         SelectionSpecification.create(Book.class)
                 .restrict(Restriction.contains(Book_.title, "hibernate", false))
                 .sort(Order.desc(Book_.title));
 var projection = ProjectionSpecification.create(specification);
 var bookIsbn = projection.select(Book_.isbn);
 var bookTitle = projection.select(Book_.title);
 var results = projection.createQuery(session).getResultList();
 for (var result : results) {
     var isbn = bookIsbn.in(result);
     var title = bookTitle.in(result);
     ...
 }
 

A ProjectionSpecification always results in a query which with result type Object[]. The select() methods return ProjectionSpecification.Element, allowing easy and typesafe access to the elements of the returned array.

Since:
7.2
API Note:
This interface marked Incubating is considered experimental. Changes to the API defined here are fully expected in future releases.