User Tools

Site Tools


query_non-entity_with_jpa

Query Non-Entity with JPA

A constructor may be used in the SELECT list to return one or more Java instances. The specified class is not required to be an entity or to be mapped to the database. The constructor name must be fully qualified.

If an entity class name is specified in the SELECT NEW clause, the resulting entity instances are in the new state.

SELECT NEW com.acme.example.CustomerDetails(c.id, c.status, o.count)
FROM Customer c JOIN c.orders o
WHERE o.count > 100

When a class is passed as the second parameter to the createNativeQuery method the values are passed either via public fields or setter methods to the new object instance.

,
query_non-entity_with_jpa.txt · Last modified: 2017/06/08 14:37 by mihael