I have one bean like:
public class Car{
String color;
List<Wheel> wheels;
....
}
And
public class Wheel{
int size;
....
}
Assuming an standard hibernate configuration configuration I may get some inserts like
insert into car (id, color) values (1,'blue')
insert into car (id, color) values (2,'red')
insert into car (id, color) values (3,'white')
and then
insert into carxwheel (idcar,idwheel) values (1,1)
insert into carxwheel (idcar,idwheel) values (2,1)
insert into carxwheel (idcar,idwheel) values (3,2)
Is it possible that if I have a denormalized table, I can get an insert into a plain table storing both entities, like:
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)
If using collections – no. You will have to “denormalize” your object model as well. That is, make your entity have 3 fields –
id,colorandwheelsize