7.2.1. 多对一(many to one)

单向many-to-one关联是最常见的单向关联关系。

  1. <class name="Person">
  2. <id name="id" column="personId">
  3. <generator class="native"/>
  4. </id>
  5. <many-to-one name="address"
  6. column="addressId"
  7. not-null="true"/>
  8. </class>
  9. <class name="Address">
  10. <id name="id" column="addressId">
  11. <generator class="native"/>
  12. </id>
  13. </class>
  1. create table Person ( personId bigint not null primary key, addressId bigint not null )
  2. create table Address ( addressId bigint not null primary key )