-->
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.  [ 2 posts ] 
Author Message
 Post subject: Specifying foreign key ids for inserts
PostPosted: Tue Jan 03, 2006 4:40 pm 
Newbie

Joined: Wed Sep 22, 2004 2:01 pm
Posts: 9
Hibernate version: 2.1.8

Name and version of the database you are using: Oracle 9

Hi Hibernators,

I have a performance-tuning question. Let's say I have a DB table called "child" which has a foreign key field called "parent_id" (integer) which, for each record, holds the id of the related record from the "parent" table. I am using hibernate to manage these "Child" objects and I want to create a new Child object which would be related to a particular Parent object. I have the parent_id value which I got from a web page form, but I don't have the corresponding Parent object. Must I get this Parent object from the DB just so I can put it on the Child object and then save the Child object? After it is inserted I am not going to make further use of either object during the session.

I guess a more generic way to ask the question is... can I manually specify the value of a foreign key field which is represented in Java-land as an Object property, or should I just use plain old SQL to do the insert?

Thanks!
-Eric


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 12:35 pm 
Regular
Regular

Joined: Thu Sep 23, 2004 11:53 am
Posts: 83
I think you have to retrieve the parent object, but you don't have to query for use Session.load or Session.get. If I am wrong about the this someone will slap me around :).


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