Entity bean Remote component interface

An entity bean’s component interface is just like a session bean’s—it has business methods, and it extends javax.ejb.EJBObject. That means a client can see the methods you’ve declared in your component interface, as well as the methods from EJBObject (getHandle(), remove(), etc.).

But what kinds of business methods go in the component interface?

The methods related to a single entity!

When the client has a reference to an entity bean (which means a reference to the bean’s EJB object, of course), the client has a reference to a single, specific entity. Fred Flintstone, #999. Marge Simpson, #728. Roy Rodgers, #1957.

So what might a client want to do with a reference to, say, Marge Simpson? Delete her, change her last name, get her handle, or get her home so that the client can get references to other customers. Keep in mind that our simple Customer bean isn’t very useful yet, with methods to get or set only the Customer name. Later, we’ll build it out.

image with no caption

Get Head First EJB 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.