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?
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With