我真的很困惑,列结果集映射如何工作?当我使用列而不是实体时,我在映射什么?看看这个例子...
Query q = em.createNativeQuery(
"SELECT o.id AS order_id, " +
"o.quantity AS order_quantity, " +
"o.item AS order_item, " +
"i.name AS item_name, " +
"FROM Order o, Item i " +
"WHERE (order_quantity > 25) AND (order_item = i.id)",
"OrderResults");
@SqlResultSetMapping(name="OrderResults",
entities={
@EntityResult(entityClass=com.acme.Order.class, fields={
@FieldResult(name="id", column="order_id"),
@FieldResult(name="quantity", column="order_quantity"),
@FieldResult(name="item", column="order_item")})},
columns={
@ColumnResult(name="item_name")}
)
我可以理解他在这里试图做什么,实体结果将是他想要的结果集,字段将尝试将字段映射到别名,列结果到底在做什么?看起来它没有映射到任何东西。