Phillip,
How many queries are required depends on the quality of your
CMP engine. I will list implementations from worst to best:
1) The CMP engine from some vendors will require 201 data
accesses: 1 for the initial finder, and then 100 to load
each bean, and 100 to store each (unmodified) bean. If you
implement a proprietary "isModified" method, then only 101
calls are required.
2) The CMP engine from other vendors will do this in 101 data
accesses. 1 call for the finder, which loads into a cache,
which allows the beans to be subsequently loaded from the
cache. Then 100 updates to do the stores.
3) The best CMP engines will require only a single data access.
That access will execute the finder and load all the beans.
The CMP engine will automatically detect that the beans were
unmodified and avoid updating the database.
<vendor>
It is left an an exercise for the reader to guess which capabilities
our CMP engine provides ;-)
</vendor>
But again, it is not the EJB spec which results in needless
database implementations. It is the CMP engines from vendors
who have not implemented all the necessary optimizations.
-jkw
"Rhodes, Phillip C." wrote:
>
> There are a lot of examples out there that illustrate Order and its
> LineItems. In these examples, there is a business method defined on Order
> remote interface called "getLineItems" which calls the findByOrder method on
> the home interface of the LineItem. The findByOrder on the remote interface
> returns an enumeration of primary keys. This does not make sense to me.
>
> Why do ejbFinder methods on the home interfaces return enumeration of
> primary keys?
> Wouldn't it be better to return enumeration of the objects themselves?
>
> If an Order object has 100 Order Line Items, this would resolve to 101
> database queries vs 1 database query!
> select * from order
> vs
> select * from order where orderid = 1
> ...
> select * from order where orderid = 100
>
> I understand the method "getLineItems" on the Order object does not have to
> call the home interface of the LineItem. Another way would be to do a
> select * from order and create all the OrderLineItem objects (instead of
> primary keys). But I wonder why this is not done in the countless examples
> that I have seen?
>
> Thanks. I appreciate your thoughts.
===========================================================================
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".