이 콘텐츠는 선택한 언어로 제공되지 않습니다.
16.4. Projection Queries
In many cases returning the full domain object is unnecessary, and only a small subset of attributes are desired by the application. Projection Queries allow a specific subset of attributes (or attribute paths) to be returned. If a projection query is used then the
Query.list()
will not return the whole domain entity (List<Object>
), but instead will return a List<Object[]>
, with each entry in the array corresponding to a projected attribute.
To define a projection query use the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
select(...)
method when building the query, as seen in the following example:
Example 16.4. Retrieving title and publication year