Session Beans Versus Entity Beans

By now, you already have a good concept of the difference between a session bean and an entity bean. The question now is, how do you go about using them from a client? Furthermore, do you even need both types of beans?

Typically, your clients don't access entity beans directly. Some EJB architects make this a hard and fast rule; others aren't as restrictive. The main reason you don't access entity beans directly is that you generally need to invoke several methods on an entity bean to perform an operation. This would require you to manage the transaction from the client, which is not very efficient.

Another reason you don't want to use entity beans directly is that the entity beans typically represent data objects ...

Get Special Edition Using Java™ 2 Enterprise Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.