一对一:从的主键应和主的一致;
主:User
[id name="id" column="id" type="long" unsaved-value="-1"]
[one-to-one name="serial" class="SysActCode" cascade="save-update" outer-join="auto" constrained="true"/]
从:Address
[id name="id" column="ID"]
[generator class="foreign"]
[param name="property"]user[/param]
[/generator]
一对多:
主:
set:
[set name="joingame" table="gf_joiningame" cascade="all"]
[key column="ballID" /]
[one-to-many class="Joiningame" /]
[/set]
list
[bag name="passengers" lazy="true" inverse="true" cascade="all-delete-orphan"]
[key column="orderID"/]
[one-to-many class="OrderPassenger"/]
[/bag]
从:
[many-to-one name="flightOrder" column="orderID" class="FlightOrder" /]
其它:较为复杂的Hibernate 数据映射:学生,班级,课程;
Student--class:多对1
Student--address:1对1
Student--course:多对多
Student.hbm.xml 中于三个对象的设置:
[set name="courses" table="Student_Course_Link" lazy="false" inverse="true" cascade="all" sort="unsorted"]
[key column="StudentId"/]
[many-to-many class="com.ivan.Course" column="CourseId" outer-join="auto"/]
[/set]
[many-to-one name="classes" class="com.ivan.Classes" cascade="none" outer-join="auto" update="true" insert="true"
column="ClassesId"/]
[one-to-one name="address" class="com.ivan.Address" cascade="all" outer-join="auto" constrained="false"/]
分享到:
相关推荐
hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,hibernate,包含4个说明文档,分别详细解说了hibernate关联映射的...
该资源包含了一些常用的hibernate关联映射实例。包括一对多,多对多,继承映射,等,是学习hibernate的必备品
Hibernate关联关系练习【全】
hibernate关联关系
映射一对多关联关系 以Customer和Order为例: 一对多: 每个Customer可以有一个或者多个Order,因此Customer中应该有一个集合类型的属性,来引用所有关联的Order对象。 多对一。全实例讲解
Hibernate关联关系映射 单向关联 │ ├─ 一对一外键单向关联 │ ├─ 一对一主键单向关联 │ ├─ 一对一连接表单向关联 │ ├─ 一对多外键单向关联 │ ├─ 一对多连接表单向关联 │ ├─ 多对一外键单向关联 │ ...
hibernate关联查询 实例源码 java web 如果不明白hibernate关联查询不明白的可以看看,保证马上学会,注释,数据库都有,很简单易学的源码,谢谢下载!
Hibernate 一对一外键单向关联 Hibernate 一对一主键单向关联 Hibernate 一对一连接表单向关联 Hibernate 一对多外键单向关联 Hibernate 一对多连接表单向关联 Hibernate 多对一外键单向关联 Hibernate 多对一连接...
Hibernate 关联关系映射分类
文件中包含关于hibernate 各个属性的解释
Hibernate关联关系.docHibernate关联关系.doc
Hibernate关联关系总结 一对多 多对一 多对多
大致总结了一下Hibernate关联关系。提供相关的一些例子进行测试。
Hibernate关联关系映射.CHM Hibernate文档相关
hibernate关联关系简单项目,也可以只运行Java文件不用JSP页面,运用MySQL
关于对Hibernate关联映射的一个总结,其中有各种映射的例子,详细用法 等
Hibernate关联关系映射实例速查,帮助初学者学习。
Hibernate关联映射.doc
hibernate关联关系多对一实例