Hibernate集合映射中的一个疑问

[复制链接]
查看11 | 回复2 | 2009-3-2 17:34:11 | 显示全部楼层 |阅读模式
在使用Hibernate中,建立了一个对象模型,内有id name普通属性外,还有List,Map,Set,String[]。随后自动导出表,生成了5张表。发出的SQL语句如下:
create table t_CollectionMapping (id number(10,0) not null, name varchar2(255 char), primary key (id))
create table t_array_value (array_id number(10,0) not null, array_value varchar2(255 char), array_index number(10,0) not null, primary key (array_id, array_index))
create table t_list_value (list_id number(10,0) not null, list_value varchar2(255 char), list_index number(10,0) not null, primary key (list_id, list_index))
create table t_map_value (map_id number(10,0) not null, map_value varchar2(255 char), map_key varchar2(255 char) not null, primary key (map_id, map_key))
create table t_set_value (set_id number(10,0) not null, set_value varchar2(255 char))
list,map,array都有联合主键。例如:primary key (map_id, map_key)),primary key (list_id, list_index))
而set却没有约束,那不是可以直接在数据库中插入重复的数据吗?请高手解释

回复

使用道具 举报

千问 | 2009-3-2 17:34:11 | 显示全部楼层
生成的SQL语句,和你直接写的,效果是一样的,Hibernate就是为了方便用户,而不用自己编写代码设计的。...
回复

使用道具 举报

千问 | 2009-3-2 17:34:11 | 显示全部楼层
我也正学hibernate呢,感觉很多东西都挺诡异的。如果那些集合都是属性里面的……不是一个类对应一张表吗……或者,所谓的继承映射组件映射?……………………晕死了,我得好好看看材料搞搞清楚...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行