Annotation Interface FieldResult
Used in conjunction with the
EntityResult annotation to map
a column specified in the SELECT list of a SQL query to a
property or field of an entity class.
The name() member specifies the name of the mapped field
or property of the entity class. If the property or field is
declared by a child embeddable object, then
name() specifies a qualified path.
Consider the following SQL query:
Query orders =
em.createNativeQuery(
"""
SELECT o.id AS order_id,
o.quantity AS order_quantity,
o.item AS order_item
FROM Order o
WHERE o.quantity > 25
""",
ResultMappings_.MAPPING_ORDERS
);
The result set mapping might be defined as follows:
@SqlResultSetMapping(
name = "Orders",
entities = @EntityResult(
entityClass = Order.class,
fields = {
@FieldResult(name = Order_.ID,
column = "order_id"),
@FieldResult(name = Order_.QUANTITY,
column = "order_quantity"),
@FieldResult(name = Order_.ITEM,
column = "order_item")
}
)
)
interface ResultMappings {}
At runtime, a FieldResult annotation is represented by an
instance of FieldMapping
in the ResultSetMapping
returned by EntityManagerFactory.getResultSetMappings(Class).
- Since:
- 1.0
- See Also:
-
Required Element Summary
Required Elements