Hibernate 单项多对一映射

 

public class Order {
private Integer orderId;
private String orderName;


private Customer customer;

}

public class Customer {
private Integer customerId;
private String sustomerName;
}

在映射多对一的关联关系时,使用 many-to-one 来映射多对一的关联关系。

<many-to-one name="customer" class="Customer" column="CUSTOMER_ID"></many-to-one>

name : 是一这一端中对应的多的那一端的 名字。

class :是一那一端的属性对应的类名。

column :是一那一端在多的一端对应的数据表中的外键的名字。

 

posted @ 2016-08-18 19:44  花猪  阅读(85)  评论(0)    收藏  举报