-->
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.  [ 5 posts ] 
Author Message
 Post subject: Can a column take dynamic values??
PostPosted: Fri Jan 27, 2006 5:55 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
Hai,

From the UI I send two objects mapped to two different tables.
My insertion order in two tables are these,

I insert the first object to the table and it generates a id based on the insertion and I use the id value which is dynamically generated as part of the second object and insert that into the second table.

Now is there a way to do this seemless with hibernate mapping.

To be more clear, can I specify a column of one table in hibernate mapping file to be dependent on the value generated by another table.

My insertion in the second table depends only when there is insertion in the first table.

Please give me some suggestions. Is there any particular topic in hibernate addressing this issue I'm working with!!!!

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
 Post subject: Re: Can a column take dynamic values??
PostPosted: Fri Jan 27, 2006 9:30 am 
Newbie

Joined: Thu Jan 26, 2006 6:19 am
Posts: 19
spatik wrote:
Hai,

From the UI I send two objects mapped to two different tables.
My insertion order in two tables are these,

I insert the first object to the table and it generates a id based on the insertion and I use the id value which is dynamically generated as part of the second object and insert that into the second table.

Now is there a way to do this seemless with hibernate mapping.

To be more clear, can I specify a column of one table in hibernate mapping file to be dependent on the value generated by another table.

My insertion in the second table depends only when there is insertion in the first table.

Please give me some suggestions. Is there any particular topic in hibernate addressing this issue I'm working with!!!!


In mapping file, set the id-generator :"assigned" so you will assign the id,
After inserting the first object, read its id, generate the second object's id, and assign it


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 9:32 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
I have made the generator as native.
I want hibernate to get the generated id and use it while saving the second object.
Is there a way to wire this mapping via the hbm file?
I don't want to read the generated id manually and use it to save the second object.

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 1:00 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
generator="foreign"

Have a look in the Hibernate reference. There is an example.

Regards Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 28, 2006 2:48 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
Thanks laliluna.
It is working fine for me now.
Guess what i took the hint from your site.

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.