Hi,
"Bhattacharyya, Ana" wrote:
>
> Hi Francis,
> Can u pls elaborate those cases where an entity bean scales more than a
> session bean.
Remember: EntityBean can be shared by multiple users and also be pooled
(like stateless session beans).
When implementing a component that's intensively exposed to concurent
access and less updated(like a game result), use stateless session beans
in combination with "static final" caches.
But when implementing an EmployeeBean (an AccountBean or even an
OrderBean), using entity bean is beter than using stateless or statefull
session beans for following reasons:
- They are less exposed to concurent access (according to their
business logic). An EmployeeBean is either accessed by the
EmployeeService or the Payroll app. and there are not 1000 thread trying
to access the same instance of imployee bean at the same time. So there
is no considerable delay due to tx lock or whatever.
- Entity bean are also pooled like stateless session beans. Even though
they need be reloaded after ejbActivate (db-call), they don't need be
stored before passivate. They are also loaded at the beginning of each
transaction, but data are cached till the end of the transaction (2
DB-Call for each tx). With stateless session bean you need to start and
end the tx for each call (no advantage). For statefull session beans,
the instance is also kept alive during the tx life time. If the
statefull session bean isn't involved in a tx, in run the risk to be
passivated by the conainer (time intensive), it can't be reused (wasting
object references. When you peform several non transactional operations,
data don't need bee reloaded. I hope you agree the fact that the time
the employee will log to the EmployeeService to access his data, and
will perform a lot of operations (see the curent loan, check calendar
and so on). If you use stateless bean for this, you will access the
database for each request, since beans are stateless (even if the
container serves you the same instance of the bean: you should never
rely on this).
To resume myself:
- never replace an entity bean with a statefull session bean.
- only replace an entity bean with a "stateless session bean + cache "
when you have intensive concurent readonly access and less need for
actuality of data being served to clients.
- by default, use entity beans to model real live entities (Customer,
Employee, Account, Order ...)
any comment?
/Francis
--
[EMAIL PROTECTED]
MATHEMA Software GmbH
N�gelsbachstra�e 25 b
91052 E r l a n g e n
D e u t s c h l a n d
Tel +49(0)9131/8903-0
Fax +49(0)9131/8903-55
http://www.mathema.de
===========================================================================
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".