Let's face it...99% of the time, the client (and good design dictates that
the client is a session bean) will have to do a findByPrimaryKey in order to
determine if that primary key is of interest to it. If you aren't using CMP,
this results in *very* poor performance especially with larger data sets.
Tricks like Rickard is suggesting are fine, but all of those selects *do*
happen.

I cannot suggest to my clients that entity bean finder methods are the way
to go. The better approach is to perform the lookup in a session bean. This
isn't a blanket statement, but 99% of the time I think I'm right. ;-)

Unfortunately, many people design a fair amount of business logic into their
entity beans. When they consider using finder methods via session beans,
they end up having to duplicate some business methods. This isn't a good
idea. Hopefully, they realize that it's not putting the finders in the
sessions that is bad design, but rather putting *any* business logic in the
entity bean is the poorer choice.

As much as I think Roger Sessions is a Microsoft tool, I think the argument
against entity beans as an inhibitor to scalability/performance is leaning
more and more to his favor. But that is a whole different thread! ;-)

jim

> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Assaf Arkin
> Sent: Saturday, January 29, 2000 2:26 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Database Optimization With Entity Beans
>
>
> 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.
>

===========================================================================
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