What’s an entity bean?
Note
Entity beans represent data in a persistent store. That almost always means that entity bean objects map to relational database rows (although it can be a lot more complex than just one instance maps to one row...)
An entity bean is an object-oriented way of looking at in a persistent store. The spec says “persistent store”, and doesn’t specify what that persistent store must be. It could be anything that satisfies the requirements of ‘persistence’ including a relational database, an object database, or even something as lame and inefficient as storing serialized objects to files. But in most real-world scenarios, we’re talking a relational database. And that means an individual row in a table maps to a unique entity bean. The object-to-relational (OR) mapping could be a lot more complex than a simple one row equals one bean scenario, but we’ll get into that in the next chapter.
Entity beans are data objects. They are...things. Nouns. As opposed to session beans which are processes. Verbs. Entity beans might represent things like people, products, orders, bookings, inventory, animals...things. Entity beans would not represent things like credit card verification, advisor service, order submission, membership registration... processes.
Of course, in virtually all well-designed EJB applications, entity beans will be combined with session beans, where the client ...
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.