13. What are life cycle methods of Session Bean?
public void setSessionContext(SessionContext ct)
public void ejbActivate()
public void ejbPassivate()
public void ejbRemove()
14. What are life cycle methods of Entity Bean?
public void setEntityContext(EntityContext ct)
public void unSetEntityContext()
public void ejbActivate()
public void ejbPassivate()
public void ejbRemove()
public void ejbLoad()
public void ejbStore()
15. What is difference between a stateless and stateful Session Beans?
Stateless Session Beans are beans that don't maintain state across method calls. They are generally intended to perform individual operations automatically. Any instance of stateless bean can be used by any client at any time.
Stateful Session Beans -maintain state within and between transactions. Each Stateful session bean is
associated with a specific client. Containers can automatically save and retrieve a beans state in the process of managing instance pools of stateful beans.
16. How do Stateful Session beans maintain consistency across transaction updates?
Stateful session beans maintain data consistency by updating their fields each time a transaction is committed. To keep informed of changes in transaction status, a stateful session bean implements the SessionSynchronization interface. The Container then calls methods of this interface as it initiates and completes transactions involving the bean.
17. What are types in Entity Beans?
Entity Beans are mainly two types:
In bean managed persistence, the bean is entirely responsible for storing and retrieving its instance data. The EntityBean interface provides methods for the container to notify an instance when it needs to store or retrieve its data.
In container managed persistence, entity bean data is automatically maintained by the container using a mechanism of its choosing.
19. How is an Entity Bean created?An Entity Bean can be created in two ways: by direct action of the client in which a create method is called on the bean's home interface or some other action that adds data to the database that the bean type represents.
20. How does a container manages access from multiple transactions on an Entity Bean?
Container can acquire an exclusive lock on the instance's sate in the database and serializable access from multiple transactions to this instance.
21. Does Enterprise JavaBeans allow alternatives to Container-Managed Transactions (CMT)?
In addition to container-managed transactions, an Enterprise JavaBeans can participate in client-managed and bean-managed transactions.
22. What is the need of Remote and Home interface. Why can’t it be in one?
The main reason is because there is a clear division of roles and responsibilities between the two interfaces. The home interface is your way to communicate with the container, that is who is responsible of creating, locating even removing one or more beans.
The remote interface is your link to the bean that will allow you to remotely access to all its methods and members. As you can see there are two distinct elements (the container and the beans) and you need two different interfaces for accessing to both of them.
23. Can I develop an Entity Bean without implementing the create () method in the home interface?
As per the specifications, there can be 'ZERO' or 'MORE' create () methods defined in an Entity Bean. In cases where create() method is not provided, the only way to access the bean is by knowing its primary key, and by acquiring a handle to it by using its corresponding finder method. In those cases, you can create an instance of a bean based on the data present in the table. All one needs to know is the primary key of that table.
i.e., Set a columns that uniquely identify a single row in that table.Once this is known, one can use the
‘getPrimaryKey () ' to get a remote reference to that bean, which can further be used to invoke business methods.
public void setSessionContext(SessionContext ct)
public void ejbActivate()
public void ejbPassivate()
public void ejbRemove()
14. What are life cycle methods of Entity Bean?
public void setEntityContext(EntityContext ct)
public void unSetEntityContext()
public void ejbActivate()
public void ejbPassivate()
public void ejbRemove()
public void ejbLoad()
public void ejbStore()
15. What is difference between a stateless and stateful Session Beans?
Stateless Session Beans are beans that don't maintain state across method calls. They are generally intended to perform individual operations automatically. Any instance of stateless bean can be used by any client at any time.
Stateful Session Beans -maintain state within and between transactions. Each Stateful session bean is
associated with a specific client. Containers can automatically save and retrieve a beans state in the process of managing instance pools of stateful beans.
16. How do Stateful Session beans maintain consistency across transaction updates?
Stateful session beans maintain data consistency by updating their fields each time a transaction is committed. To keep informed of changes in transaction status, a stateful session bean implements the SessionSynchronization interface. The Container then calls methods of this interface as it initiates and completes transactions involving the bean.
17. What are types in Entity Beans?
Entity Beans are mainly two types:
- Bean Managed
- Container Managed
In bean managed persistence, the bean is entirely responsible for storing and retrieving its instance data. The EntityBean interface provides methods for the container to notify an instance when it needs to store or retrieve its data.
In container managed persistence, entity bean data is automatically maintained by the container using a mechanism of its choosing.
19. How is an Entity Bean created?An Entity Bean can be created in two ways: by direct action of the client in which a create method is called on the bean's home interface or some other action that adds data to the database that the bean type represents.
20. How does a container manages access from multiple transactions on an Entity Bean?
Container can acquire an exclusive lock on the instance's sate in the database and serializable access from multiple transactions to this instance.
21. Does Enterprise JavaBeans allow alternatives to Container-Managed Transactions (CMT)?
In addition to container-managed transactions, an Enterprise JavaBeans can participate in client-managed and bean-managed transactions.
22. What is the need of Remote and Home interface. Why can’t it be in one?
The main reason is because there is a clear division of roles and responsibilities between the two interfaces. The home interface is your way to communicate with the container, that is who is responsible of creating, locating even removing one or more beans.
The remote interface is your link to the bean that will allow you to remotely access to all its methods and members. As you can see there are two distinct elements (the container and the beans) and you need two different interfaces for accessing to both of them.
23. Can I develop an Entity Bean without implementing the create () method in the home interface?
As per the specifications, there can be 'ZERO' or 'MORE' create () methods defined in an Entity Bean. In cases where create() method is not provided, the only way to access the bean is by knowing its primary key, and by acquiring a handle to it by using its corresponding finder method. In those cases, you can create an instance of a bean based on the data present in the table. All one needs to know is the primary key of that table.
i.e., Set a columns that uniquely identify a single row in that table.Once this is known, one can use the
‘getPrimaryKey () ' to get a remote reference to that bean, which can further be used to invoke business methods.