If you only want to change your primary keys into remote references, let
the EJB Container do this job for you. You have to write a finder method
in your entity bean which selects the same IDs as your direct JDBC
query. The return value could be a java.util.Collection and it contains
the remote references. You get the references with only one DB query. If
your query is not too complex this has to work with BMP and CMP.

The wasteful part appears when you call get() methods on the references.
So if you are reading more columns than the primary key and you have to
read n rows this results in n+1 DB querys.

Tobias

Bryan Field-Elliot schrieb:
> 
> 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
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to