标签:-- gen pre logs integer color ges nat 文件
一对一关系映射即关系双方都只含有对方的一个引用(eg:人和身份证)
一对一关系映射又分为唯一外键关联映射和主键关联映射
public class Person {
private Integer id;
private String name;
//关联身份证
private Card card;
public Person() {
super();
// TODO Auto-generated constructor stub
}
}
public class Card {
private Integer id;
private String cardno;
//关联公民
private Person person;
public Card() {
super();
// TODO Auto-generated constructor stub
}
}
<one-to-one name="card" class="Card" />
只要含有外键,,,无论是一对一还是一对多,都配置many-to-one
<many-to-one name="person" class="Person" column="person_id" unique="true" />
<!-- 一对一映射 -->
<one-to-one name="card" class="CardPK" />
<!-- 关联主键(一对一) -->
<one-to-one name="person" class="PersonPK" constrained="true" />
标签:-- gen pre logs integer color ges nat 文件
原文地址:http://www.cnblogs.com/roxy/p/7611200.html