public class User {
private int id;
private String username;
private IdCard idCard;
}
private int id;
private String username;
private IdCard idCard;
}
public class IdCard {
private int id;
private String cardNO;
private int id;
private String cardNO;
}
<class name="IdCard">
<id name="id" >
<column name="t_id" />
<generator class="native"></generator>
</id>
<property name="cardNO" >
<column name="cardNO" length="50" />
</property>
</class>
<id name="id" >
<column name="t_id" />
<generator class="native"></generator>
</id>
<property name="cardNO" >
<column name="cardNO" length="50" />
</property>
</class>
<class name="User" >
<id name="id" >
<column name="t_id" />
<generator class="native"/>
</id>
<property name="username"/>
<many-to-one name="idCard" unique="true"> </many-to-one>
</class>
<id name="id" >
<column name="t_id" />
<generator class="native"/>
</id>
<property name="username"/>
<many-to-one name="idCard" unique="true"> </many-to-one>
</class>
一对一外键关联映射_单向,其实就是多对一映射的一种特例,就是把多的一端的外键加一个unique="true"