我有一个像:
的豆子public class Car{
String color;
List<Wheel> wheels;
....
}
并且
public class Wheel{
int size;
....
}
假设标准的hibernate配置配置,我可能会得到一些插件,如
insert into car (id, color) values (1,'blue')
insert into car (id, color) values (2,'red')
insert into car (id, color) values (3,'white')
然后
insert into carxwheel (idcar,idwheel) values (1,1)
insert into carxwheel (idcar,idwheel) values (2,1)
insert into carxwheel (idcar,idwheel) values (3,2)
如果我有一个非规范化的表,我可以插入一个存储两个实体的普通表,如:
insert into car (id, color, wheelsize) values (1,'blue', 20)
insert into car (id, color, wheelsize) values (1,'blue', 30)
insert into car (id, color, wheelsize) values (1,'blue', 40)
insert into car (id, color, wheelsize) values (2,'blue', 10)
insert into car (id, color, wheelsize) values (2,'blue', 30)
insert into car (id, color, wheelsize) values (2,'blue', 40)
答案 0 :(得分:1)
如果使用收藏品 - 没有。您还必须对对象模型进行“非规范化”。也就是说,让您的实体有3个字段 - id
,color
和wheelsize