This is one of the downsides of most common implementations of the EJB entity
bean spec.  One way we can seek to optimize this in a future release is to
support recordsets where we cache query results and use client-side cursor
access to cache 100 or so fields at a time.  If you need more sophisticated
caching then you do have to fall back on bean-managed persistence.  Issuing a
query for every CMP access is a huge performance penalty.  I see no reason why
the ejb entity bean container's resource manager can't use a smarter connection
pooling mechanism in combination with recordset (i.e. cursor) technologies to
facilitate fast object mapping access.  This gives the performance of the ejb
container simply creating an entity bean and stuffing it with cached recordset
values upon request.  For instance, a findByPrimaryKey would run against the
recordset and automagically prompt cursor movement if the cache does not contain
the appropriate data set.

Bryan Field-Elliot wrote:

> This question is one of optimization and improving performance:
>
> I need to create an array of entity bean references. I already have an array
> of primary keys, which I get from a direct JDBC query. I need to convert
> these primary keys into entity bean references. The "obvious" way to do this
> is to iterate through the array and call "findByPrimaryKey" for each of
> these references. However, this results in what appears to be a wasteful
> query, for every call to findByPrimary Key:
>
> select id from my_table where id = ?
>
> This is useless, and yet it gets called with every call to findByPrimaryKey.
> The rest of the columns are only pulled in when the client actually calls
> one of the get() methods on my beans:
>
> select col1, col2, col3, ... from my_table where id = ?
>
> So you see, I'd like to skip the calling of the first query altogether. Is
> there a way I can do this with JOnAS?
>
> By the way, these are CMP entity beans. I suspect I can get the behavior I
> want with BMP, but I would like to stay CMP if at all possible (saves a lot
> of work).
>
> Thank you,
> Bryan
> ----
> This list is cross-posted to two mail lists.  To unsubscribe,
> follow the instructions below for the list you subscribed to.
> For objectweb.org: send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe ejb-container-group".
> For enhydra.org: send email to [EMAIL PROTECTED] and include
> in the body of the message "unsubscribe ejb-container-group".

----
This list is cross-posted to two mail lists.  To unsubscribe,
follow the instructions below for the list you subscribed to.
For objectweb.org: send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe ejb-container-group".
For enhydra.org: send email to [EMAIL PROTECTED] and include
in the body of the message "unsubscribe ejb-container-group".

Reply via email to