Purushotham Das K wrote:
>
> hi folks,
>
> I am in a dilemma whether to go for JDBC from the session bean
> directly or use an entity bean for querying the database . Can some one tell
> me which I should use and when should i go for either of them and also which
> will be more efficient performance-wise.
>
> Thanks in advance
> Purush
>
> ===========================================================================
> 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".
Purushotham,
Both alternatives work.
One of the major reasons for using the entity bean alternative is to
provide a more formal entity 'tier' as a service rather than as a
library of data access objects. One of the benefits of having a more
formal entity service tier is that it factors this into a shared service
that can be independently administered rather than proliferating
multiple copies of a DAO library hidden away in several applications.
Adding an EJB entity 'tier' does add some overhead for container
management; however, this is smaller than many people think.
As for the query issue that was raised in this thread, it is true that
any solution that iterates across large numbers of entities will likely
be inefficient; however, there is no need to implement queries this way.
Queries should be implemented by the entity tier itself and use the
underlying services of the database directly.
If aggregate information needs to be returned, this should be
implemented as an aggregate information service which is part of the
tier. One way to do this is to implement it as a Session EJB that is a
partner of its Entity EJB and shares the same underlying database
schema. Together they provide an efficient abstraction of the entity
tier. In EJB 2.0, the aggregate service can be implemented as Home
methods on the entity (which simplifies this pattern somewhat).
-- Mark
===========================================================================
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".