Selecting specific columns in jpa 2 Criteria API?
10,541
Yes, it does. The select() method is what you need to use. From the openJPA manual:
The select() method defines the result of the query. If left unspecified, the select projection is assumed to be the root domain object. However, you can specify the selected projections explicitly as a list:
qdef.select(customer.get(Customer_.name), order.get(Order_.status));
Author by
Joopiter
A Java Developer since 2008 and likes to explore and experiment on new technologies.
Updated on June 04, 2022Comments
-
Joopiter almost 2 years
Is there a way to select specific column using the JPA 2 Criteria API?
The following is the target SQL Statement:
SELECT column1, column2 FROM MyTableThatHasMultipleColumns
With Hibernate's Criteria API this can be done using Projections, is there an equivalent to the JPA 2 Criteria Specification?