基于外键关联的一对多单向关联

基于外键关联的单向一对多关联是一种很少见的情况,并不推荐使用。 

<class name="Person">
    <id name="id" column="personId">
        <generator class="native"/>
    </id>
    <set name="addresses">
        <key column="personId" 
            not-null="true"/>
        <one-to-many class="Address"/>
    </set>
</class>

<class name="Address">
    <id name="id" column="addressId">
        <generator class="native"/>
    </id>
</class>
create table Person ( personId bigint not null primary key )
create table Address ( addressId bigint not null primary key, personId bigint not null )
        

http://lavasoft.blog.51cto.com/62575/39317

posted @ 2012-09-09 11:08  haiwei.sun  阅读(137)  评论(0编辑  收藏  举报
返回顶部