Best Practices

You should consider using a session bean if only one client has access to the bean instance and the state of the bean is not persistent. An entity bean is best used if multiple clients can access the bean and the state of the bean is persistent. You should consider using a message-driven bean when you want to develop loosely coupled systems and process asynchronous messages.

Deciding on remote or local access depends on several factors. If your client runs on a different JVM or machine, you must provide remote access. For example, in large production systems, Web components might run on a different machine. On the other hand, entity beans with container-managed relationships (CMR) with other entity beans (discussed on Day 11) must ...

Get Sams Teach Yourself EJB in 21 Days 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.