Differences

This shows you the differences between two versions of the page.

Link to this comparison view

query_non-entity_with_jpa [2017/06/08 16:37]
query_non-entity_with_jpa [2021/04/05 11:23] (current)
Line 1: Line 1:
 +====== Query Non-Entity with JPA ======
  
 +<blockquote>
 +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.
 +
 +<sxh sql>
 +SELECT NEW com.acme.example.CustomerDetails(c.id, c.status, o.count)
 +FROM Customer c JOIN c.orders o
 +WHERE o.count > 100
 +</sxh>
 +</blockquote>
 +
 +<note>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.</note>
 +
 +{{tag>jpa sql}}