<one-to-one name="iUser" constrained="true"></one-to-one>
就是 这个类的 主键参考了 IUser类,这里iuser实施外键。例如,icard 完全参考了 iuser,作为外键和主键。constrained是约束
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.sm.hibernate.pojo">
<class name="ICard" table="icard">
<id name="id">
<generator class="foreign">
<param name="property">iUser</param>
</generator>
</id>
<property name="name" not-null ="true"></property>
<one-to-one name="iUser" constrained="true"></one-to-one>
</class>
</hibernate-mapping>