-->
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: [Advice needed] where to associate child objects with Parent
PostPosted: Sun Mar 07, 2004 11:14 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
Vital stats: Hibernate 2.1.2.

A parent class, Foo, has a one to many relationship with child class, Bar.

Which of this design is better and why ?

#1) The client program performs the association task.

e.g. In the web tier

Code:
    Foo f = new Foo();
    Bar b1 = new Bar();
    Bar b2 = new Bar();

     f.addBar( b1 ); f.addBar( b2 );
     delegate.createFoo( f );


#2) the SLSB (session bean) performs the association

Code:
    Foo f = new Foo();
    Bar b1 = new Bar();
    Bar b2 = new Bar();

    delegate.createFoo( f );
    delegate.addBarToFoo( f, b1 );
    delegate.addBarToFoo( f, b2 );


Thanks a million.

Regards,

Alistair


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 07, 2004 11:34 pm 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
I prefer the first one :-)

Cheers

_________________
<name>arin</name>
<at>netplus software</at>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 08, 2004 12:22 am 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
Why is the first design preferable ?

Regards,

Alistair


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 08, 2004 8:41 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
More OO, less SLSB usage, transaction isolation

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 2:41 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
Lets delegate obj do the things that it supposes to do , Make sense for me and easy to understand, anyway this is my personal opinion.
Cheers
roofimon

_________________
<name>arin</name>
<at>netplus software</at>


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.