hibernate映射文件基础

一、利用hibernate的eclipse插件快速生成实体类与配置文件的方法

1.首先下载安装和自己的eclipse版本配套的hibernate tools,如果是Myeclipse,在/readme/readme_eclipse.html中可以找到eclipse的版本信息(不过Myeclipse一般都已经集成了hibernate tools)

2.打开hibernate tools,在db Browser里新建连接,打开连接,打开数据库,在表上面右键hibernate reverse engine,就可以生成实体类和对应的映射文件了。

二、不同关系的映射

多对一:
<many-to-one name="" class="" column=""></many-to-one>
一对多:
<set name="">
<key column=""></key>
<one-to-many class=""/>
</set>
多对多:
<set name="" table="">
<key column=""></key>
<many-to-many class="" column=""></many-to-many>
</set>

原文地址:https://www.cnblogs.com/Mr-Nobody/p/3477388.html