We use CMP beans extensively, and I am examing the code generated by GenIC
for "JOnAS###Bean###Home" and "JOnAS###Bean###" (where ### is the name of my
bean). This is the code which implements the JEntityHome and JBeanEntity
interfaces.
 
It seems that _two_ queries get issued for every finder method, but it seems
to me that the job can be done with only one. This is a big performance
problem for us, and would be a great performance boost if we could make it
into one query.
 
For example, if I have a table called "Employees" with a primary key "id"
and other fields "name" and "job", then a findByPrimaryKey(100) would result
in the following two queries:
 
select Employees.id from Employees where Employees.id=?
select Employees.id, Employees.name, Employees.job from Employees where
Employees.id=?
 
The first is issued by the Home interface implementation
(pkFindByPrimaryKey), and the second is implemented by the Bean
implementation (loadData).
 
As far as I can see, the first query is a big waste of resources, and pretty
much cuts performance in half. I don't understand why the first query is
executed at all, since it's function (to check whether or not the row
exists) can be performed by the second query just as well.
 
Can someone please explain why it works this way, and if possible, how to
optimize it?
 
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".

Reply via email to