使用Hibernate我可以使用join
来映射实体中的字段。
- 示例 -
如果我有以下课程:
public class Order{
private String orderNum;
private String productName;
private String productCost;
private String recipientName;
private String recipientAddress1;
}
我可以使用以下Hibernate映射映射该类:
<class name="Order" table="order">
<property name="orderNum" type="java.lang.long" column="order_num" />
<join table="product">
<subselect>
SELECT o.order_id, p.name, p.cost
FROM product p INNER JOIN order o ON o.product_id = p.product_id
</subselect>
<key column="order_id" />
<property name="productName" type="java.lang.String" column="name" />
<property name="productCost" type="java.lang.Double" column="cost" />
</join>
<join table="recipient">
<subselect>
SELECT o.order_id, r.name, r.address1
FROM recipient r INNER JOIN order o ON o.recipient_id = r.recipient_id
</subselect>
<key column="order_id" />
<property name="recipientName" type="java.lang.String" column="name" />
<property name="recipientAddress1" type="java.lang.String" column="address1" />
</join>
</class>
是否有JPA注释提供相同的功能?