Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Pattern »

Re: EJB relationship

Ricardo Moura

2004-03-25


Maybe I hadn't gotten to do a explanation very well about my problem.

If I want to add a B to A I will need to do something like below, won't I ?

1) A a = home.findByPrimaryKey(x);
2) Collection bs = a.getBs(); ==============> The problem is here
3) B b = home2.findByPrimaryKey(y);
4) bs.add(b);

When the line 2 is executed, the EJBContainer load ALL Bs of A to the
Collection bs, isn't it ?
So, imagine if I have 1000000 of Bs. This will be a overhead unacceptable.

Has anybody a suggestion ?



>From: Igor Cunko <icunko@(protected)>
>Reply-To: An interest list for Sun Java Center J2EE Pattern Catalog
><J2EEPATTERNS-INTEREST@(protected)>
>To: J2EEPATTERNS-INTEREST@(protected)
>Subject: Re: EJB relationship
>Date: Thu, 25 Mar 2004 14:23:41 -0500
>
>You also have findByPrimaryKey on each bean. Use it for adding specific
>bean
>to the collection / relation.
>
>Igor
>
> > -----Original Message-----
> > From: Ricardo de Souza Moura [mailto:ricsouzamoura@(protected)]
> > Sent: Thursday, March 25, 2004 1:23 PM
> > To: J2EEPATTERNS-INTEREST@(protected)
> > Subject: EJB relationship
> >
> > Imagine that I have two Entity Beans A and B.
> > The relashionship between them is mxn.
> >
> > A have a getBs() method that return a Collection of B and B have a
>getAs()
> > method that return a Collection of A.
> >
> > if I want to put a B into the A, I need call the getBs() method from A
>and
> > call add() from Collection, isn't it ?
> >
> > But when I call the getBs() method, the container load all Bs to A.
> > Imagine
> > if I had 1000000 Bs in the A.
> >
> > What is the solution to this challenge ?
> >
> > Thanks
> >
> > _________________________________________________________________
> > MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
> >
> > ====================================================================
> > Companion Site: http://www.corej2eepatterns.com
> > J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
> > List Archive: http://archives.java.sun.com/archives/j2eepatterns-
> > interest.html
> > Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
> > listserv@(protected)
>
>====================================================================
>Companion Site: http://www.corej2eepatterns.com
>J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
>List Archive:
>http://archives.java.sun.com/archives/j2eepatterns-interest.html
>Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
>listserv@(protected)

_________________________________________________________________
MSN Messenger: converse com os seus amigos online.
http://messenger.msn.com.br

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.