-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Native Sequence Usage
PostPosted: Sun Oct 28, 2007 9:36 pm 
Newbie

Joined: Sun Oct 28, 2007 9:33 pm
Posts: 3
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 6:26 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 11:11 am
Posts: 24
Location: India
Put the DETAIL in the MASTER as set/list/bag.(better go through the reference pdf for more details). then only save the msater. use generator class as native in the mapping file. This would solve ur problem.


Top
 Profile  
 
 Post subject: Native Sequence Usage
PostPosted: Mon Oct 29, 2007 7:52 pm 
Newbie

Joined: Sun Oct 28, 2007 9:33 pm
Posts: 3
I dont want alternative because My project is using sequence already and I want to utilize it using Hibernate built in technique If it has the same.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.