An entity bean’s client view

Our Customer bean isn’t finished, so don’t get too attached to it! And in fact, the code is an example of bean-managed persistence (BMP) which we really won’t be using in this book. We’ll talk a little about BMP, and a lot about its much more popular counterpart—container-managed persistence (CMP) in this chapter and the next. For now though, we’ll focus on the client view of an entity bean, and this simple bean is just to get you started looking at entity bean code.

Given that a Customer bean represents a Customer entity (i.e. a real customer) in the underlying database, what behaviors should the entity bean have? In other words, what kinds of things might the client want to do with either a single Customer or multiple Customers?

Things you’d do with a database record! The things we mentioned earlier including make a new Customer, delete a Customer, update a Customer’s fields (columns), and query/search on the Customer database.

Brain Power

Think about the following operations, and figure out which of the two client interfaces (component or home), is better suited for each operation. Keep in mind that the rules for entity bean interfaces might be different from session bean interfaces. If you think both interfaces are appropriate, check them both. (We’ve done the first one for you.)

Make a new customer

Change an existing customer’s phone number

Find all the ...

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.