The client wants to do database stuff, but in a Java OO way.
Make a new entity (an SQL INSERT)
Delete an entity (an SQL DELETE)
Update entity state (an SQL UPDATE)
Search/query on entities (an SQL SELECT)
The client interface for an entity bean is a little different from that of a session bean. For example, when a session bean client wants to get a bean, so that it can call the bean’s business methods, the client calls create() and the Container allocates a new EJB object.
But what if a client wants to use an existing entity bean? For example, what if the client doesn’t want just some random entity, but wants the EJB object of a specific entity, say, Bart Simpson # 12? In that case, a create() won’t work. The client doesn’t want a new entity, but wants a reference to an existing entity. So as you’ll see in a minute, the client interface for an entity bean adds (and must have) one or more finder methods.
The next two pages are high-level pictures of how entity beans are created (insert), and found (select). The scenarios in these pictures will be filled in with a lot more detail as we go through this chapter, but for now you can relax.
Entity bean overview
Scenario: client wants a reference to an existing entity
After doing a JNDI lookup on the entity ...