concept concept in category ejb

This is an excerpt from Manning's book EJB 3 in Action, Second Edition.
Figure 1.3 shows domain-driven architecture. The term domain-driven design may be relatively new but the concept is not (see Domain-Driven Design: Tackling Complexity in the Heart of Software, by Eric Evans [Addison-Wesley Professional, 2003]). DDD emphasizes that domain objects should contain business logic and shouldn’t just be dumb replicas of database records. Domain objects can be implemented as entities in JPA. With DDD, a Catalog object in a trading application might, in addition to having all the data of an entry in the catalog table in the database, know not to return catalog entries that aren’t in stock. Being POJOs, JPA entities support OO features, such as inheritance and polymorphism. It’s easy to implement a persistence object model with the JPA and to add business logic to your entities. Now, DDD still utilizes a service layer or application layer (see Patterns of Enterprise Application Architecture, by Martin Fowler [Addison-Wesley Professional, 2002]). The application layer is similar to the business logic layer of the traditional four-tier architecture but much thinner. EJB works well as the service-layer component model. Whether you use the traditional four-tier architecture or a layered architecture with DDD, you can use entities to model domain objects, including modeling state and behavior. We’ll discuss domain modeling with JPA entities in chapter 7.
In this chapter we covered the EntityManager. You learned how to use the EntityManager to persist, find, merge, and remove entities—the EntityManager equivalent of the basic database CRUD operations. We also discussed persistence contexts and scopes, new/detached objects versus managed objects, and the concept of merging objects. In addition, we briefly mentioned application-managed EntityManager that can be used for fine-grained control of persistence and transactions via the EntityManagerFactory. Following the discussion of the EntityManager, we briefly discussed querying—first discussing static versus dynamic queries and then covering basic JPA queries with simple JPQL, Criteria API, and native queries.