hibernate映射关系之多对多外键关联映射——xml配置

flower和catalog是多对多的关系

  Catalog.hbm.xml文件
<set name="flowers" inverse="true" table="flower_catalog" catalog="flower" lazy="false"> <key><!-- key是本尊派到外面代表本尊的人--> <column name="catalog_id" not-null="true" /> </key> <many-to-many entity-name="com.jikexueyuan.entity.Flower">
          <!--这个column是外面接待本尊派去的人--> <column name="flower_id" not-null="true" /> </many-to-many> </set
Flower.bhm.xml文件
 <set name="catalogs" table="flower_catalog" catalog="flower">
            <key><!-- key是本尊派到外面代表本尊的人-->
                <column name="flower_id" not-null="true" />
            </key>
            <many-to-many entity-name="com.jikexueyuan.entity.Catalog">
            <!--这个column是外面接待本尊派去的人-->
            <column name="catalog_id" not-null="true" />
        </many-to-many>
</set>

 

posted @ 2017-03-23 11:10  我们不该这样的  阅读(149)  评论(0编辑  收藏  举报