-->
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.  [ 1 post ] 
Author Message
 Post subject: Relation objects
PostPosted: Tue Jan 25, 2005 4:46 am 
Beginner
Beginner

Joined: Mon Jan 24, 2005 11:56 am
Posts: 24
Hi,

If we have two classes that one contains another like
Public class A{
B
}

what is the best approch for inserting A

B foundedB = findByPk("an id of object b");
a.setB (foundedB)
insert(a)

OR
B b=new B();
b.setId("an id of object b");
a.setB (foundedB)
insert(a)

As you found in first approch we find b object and then set it to a, in second one we new b object set it id property to a an insert it. We think first approch is a real OR approch but needs an extra findByPk from database, second one does not need a lookup from b, but is not an OR approch and is not recomanded.

Are we correct?


Regards,
Alireza Fattahi


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

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.