Hibernate单向一对一

<hibernate-mapping package="com.allanlxf.hibernate.association.o2o.entity">   
  <class name="Car" table="car_pk_single" >   
    <id name="id" column="id" type="integer">   
      <generator class="foreign">   
        <param name="property">engine</param>   
      </generator>   
    </id>   
    <one-to-one name="engine" class="Engine"  constrained="true" />   
  </class>   
</hibernate-mapping>   
   
<hibernate-mapping package="com.allanlxf.hibernate.association.o2o.entity">   
  <class name="Engine" table="engine_pk_single" >   
    <id name="id" column="id" type="integer">   
      <generator class="native"></generator>   
    </id>   
  </class>   
</hibernate-mapping>

相关推荐