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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.