2007-11-11
Hibernate的集合映射
Hibernate中将集合分为四类:
1、bag类:元素无序,可重复
2、set类:元素无序,不可重复
3、list类:元素有序,可重复
4、array类:数组
5、map类:映射关系
除bag类集合外,其它集合均可在Java API中找到对应接口。
Bag一般使用list来映射
java 代码
- "unitNames" table="unit" lazy="false" order-by="unit_id desc">
- "building_id"/>
- "unit_name" type="string"/>
Set集合在使用上与bag大至相同:
java 代码
- <set name="names" table="person_names">
- <key column="person_id"/>
- <element column="person_name" type="string"/>
- </set>
- <list name="unitNames" table="unit" lazy="false" >
- <key column="building_id"/>
- <index column="unit_id" />
- <element column="unit_name" type="string"/>
- </list>
- <list name="carComponents“ table="CarComponents">
- <key column="carId"/>
- <list-index column="sortOrder"/>
- <composite-element class="CarComponent">
- <property name="price"/>
- <property name="type"/>
- <property name="serialNumber" column="serialNum"/>
- </composite-element>
- </list>
- <map name="unit" table="unit">
- <key column="building_id"></key>
- <map-key column="id" type="int" />
- <element type="string" column="unit"></element>
- </map>
发表评论
- 浏览: 1433 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
最新评论
-
关于web网络拓扑图的实现
我以前做demo的时候,给人家做过一个. 其实在拓扑这块, 我几乎没有写什么, ...
-- by grandboy -
关于web网络拓扑图的实现
yyg1107 写道vml做过一个,不过不是太理想~ 关注! 前不久在jav ...
-- by kimmking -
关于web网络拓扑图的实现
vml做过一个,不过不是太理想~ 关注!
-- by yyg1107 -
Spring OpenSessionInView
execution(* com.baoler.manager..*(..))" ...
-- by kevin002 -
Spring OpenSessionInView
那么多*, public * com.baoler.manager.**.*(. ...
-- by Fly_m






评论排行榜