Interface SimpleProjectionSpecification<T,X>

Type Parameters:
T - The result type of the SelectionSpecification
X - The type of the projected path or attribute
All Superinterfaces:
QuerySpecification<T>

@Incubating public interface SimpleProjectionSpecification<T,X> extends 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 Incubating is considered experimental. Changes to the API defined here are fully expected in future releases.