Parikshit Pol wrote:
> Yes, you can write finder methods in Home Interface of entity Bean
> which will returns an Enumeration of entity beans.This will be
> equivalent to writing a single SQL stt. which returns n rows. Each
> entity bean in the enumeration will represent a single row in the
> table. Always think as Home Interface as a container of Multiple
> RI's and Entity Beans.
Okay, let's take this step by step. Tell me when I go off track.
With Bean-Managed Persistence:
A client calls the personHome.findByName("bob") in the
server-generated implementation of the PersonHome interface.
The server duly calls personBean.ejbFindByName("bob").
Using a single SQL SELECT statement that looks like:
SELECT id FROM person WHERE name like "bob%"
the 20 people called "bob" are found, so this returns an Enumeration
containing the primary keys for those twenty entities.
[[I'm guessing here]] The server then calls
personBean.ejbFindByPrimaryKey(keyI) 20 times to build an enumeration
of those twenty people. Each call may involve a single SQL SELECT
statement, but it will be executed twenty times:
SELECT name, address, phone FROM person
WHERE id = ?
Eventually, the server returns to the client an Enumeration containing
20 instances of the server-generated implementation of the Person
interface.
Is that what typically happens? In that case, that's pretty
inefficient, because the second SQL SELECT statement was executed 20
times.
With Container-Managed Persistence, a decent O/R tool should be able
to do it all in one SQL statement that looks like:
SELECT id, name, address, phone FROM person
WHERE name LIKE "bob%"
Much more efficient.
- Rujith.
===========================================================================
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".