I tried this but I really couldnt figure out if this can be done or not. Consider the following case
1. There is a Master detail Relation
2. Primary key in master table is generated using sequence
3. This generated id will also be used in detail table
In order to do above scenario, I have to take following steps (Correct me id I am wrong)
1. Bean Mapped to Master table needs to be saved first
2. Put any query to get primary key generated while above save operation using other data field of the table
3. Populate your Master bean with primary key
4. Set the primary key in all the details that needs to be saved
Now, here I can see over head of one query (Step 2) just because we are not populating our bean with primary key while persisting it.
By any mechanism if hibernate saves the primary key value in the associated bean after querying (SELECT seq.nextval from dual) then
Step 2 can be avoided.
|