If you only care about the primary key, then you need that one single
SQL statement. But if you actually need the entity bean and it's
identity, then each one has to be loaded separately.

This happens by the container calling ejbFindByPrimaryKey with the
primary key. The container may do so only when the entity bean is first
accessed, not all 1+n selects at once, so if you only need two Bobs out
of twenty, there are only three selects. But if you need all 20 Bobs,
you get 21 selects.

arkin


Gene De Lisa wrote:
>
> > Date:    Fri, 28 Jan 2000 11:26:57 -0500
> > From:    Rujith de Silva <[EMAIL PROTECTED]>
> > Subject: Re: Database Optimization With Entity Beans
> >
> > Okay, let's take this step by step.  Tell me when I go off track.
> >
> > With Bean-Managed Persistence:
> >
> > A client calls the personHome.findByName("bob") in the
> > server-generated implementation of the PersonHome interface.
> >
> > The server duly calls personBean.ejbFindByName("bob").
> >
> > Using a single SQL SELECT statement that looks like:
> >
> >     SELECT id FROM person WHERE name like "bob%"
> >
> > the 20 people called "bob" are found, so this returns an Enumeration
> > containing the primary keys for those twenty entities.
> >
> > [[I'm guessing here]] The server then calls
> > personBean.ejbFindByPrimaryKey(keyI) 20 times to build an enumeration
> > of those twenty people.  Each call may involve a single SQL SELECT
>
> Since you asked, you get off track right there. :)
>
> Why are you thinking that ejbFindByPrimaryKey is called here. You've just
> returned the primary keys to the container so they already have them.
>
> It goes like this:
> for bmp the container calls ejbFind... to match the find... in the home. The
> ejbFind returns the pks to the container. The container then creates (or
> gets from a cache) ejbobjects and shoves the pk into them. that is for each
> pk there will be one ejbobject with the pk inside it. references to the
> ejbobjects are then returned. At this point there are no bean instances
> involved. The only sql executed was in the single ejbFind...
>
> Gene De Lisa
> Rockhopper Technologies, Inc.
> 75 Trueman Ave.
> Haddonfield, NJ 08033-2529
> (856) 616-0950 office
> http://www.rockhoppertech.com
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to