Session bean
|
Entity bean
|
Represents a single conversation with a client.
Typically, encapsulates an action
or actions to be taken on business data.
|
Typically, encapsulates persistent
business data—for example, a row in a database.
|
Is relatively short-lived.
|
Is relatively long-lived.
|
Is created and used by a single
client.
|
May be shared by multiple clients.
|
Has no primary key.
|
Has a primary key, which enables
an instance to be found and shared by more than one client.
|
Typically, persists only for the
life of the conversation with the client. (However, may choose to save
information.)
|
Persists beyond the life of a
client instance. Persistence can be CMP or BMP.
|
Is not recoverable—if the EJB
server fails, it may be destroyed.
|
Is recoverable—it survives
failures of the EJB server.
|
May be stateful (that is, have a
client-specific state) or stateless (have no non-transient state).
|
Is typically stateful.
|
May or may not be transactional.
If transactional, can manage its own OTS transactions, or use
container-managed transactions.
A stateful session bean that
manages its own transactions can begin an OTS transaction in one method and
commit or roll it back in a subsequent method.
A stateless session bean that
manages its own transactions and begins an OTS transaction must commit (or
roll back) the transaction in the same method in which it was started.
The state of a transactional,
stateful session bean is not automatically rolled back on transaction
rollback. In some cases, the bean can use session synchronization to react to
syncpoint.
|
May or may not be transactional.
Must use the container-managed transaction model.
If transactional, its state is
automatically rolled back on transaction rollback.
|
Is not re-entrant.
|
May be re-entrant.
|
A session bean usually performs
operations such as calculations or database access on behalf of the
client.
|
An entity bean is an object
representation of persistent data maintained in a permanent data store such
as a database
|
Business layer ( calculations
based on business rules)
|
Data layer (Object representation of
Database rows)
|
Stateless beans can be pooled
|
Entity beans can be pooled
|
·
Component Interface
·
Home Interface
·
Bean Class
|
· Component Interface
· Home Interface
· Entity bean class/Primary key class/other
helper class if needed
· Deployment descriptor
|
Monday, June 18, 2012
Session bean vs Entity bean
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment