|
There are two issues, that I am having a hard time figuring out the best approach, with Sequence generation for PK and associating them by FK's:
1) I noticed that there seems to be no way to get hibernate to include a myseq.nextval in the insert statement for the object. Any ideas on this?
2) It would be nice that if hibernate notice, that the parent and FK-dependent objects were getting inserted all at once (or should go in one shot), that it would get the parent_id and assign as FK ids to the dependent objects all in one statement to the DATABASE – one IO not MANY (get Ids first, then do inserts for each of the objects). In Oracle you’d send a PLSQL block like pseudo code:
BEGIN
Insert into parent values(parent_seq.nextval, ‘data,data,data’);
fk_parent:= parent_seq.currval;
Insert into child values (fk_parent, ‘child data1’);
Insert into child values (fk_parent, ‘child data2’);
END;
Is there any such way in Hibernate?
Thanks!
|