Tham khảo tài liệu 'manning hibernate in action phần 2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 20 CHAPTER 1 Understanding object relational persistence Considering EJB entity beans In recent years Enterprise JavaBeans EJBs have been a recommended way of persisting data. If you ve been working in the field of Java enterprise applications you ve probably worked with EJBs and entity beans in particular. If you haven t don t worry entity beans are rapidly declining in popularity. Many of the developer concerns will be addressed in the new EJB specification however. Entity beans in the current EJB specification are interesting because in contrast to the other solutions mentioned here they were created entirely by committee. The other solutions the DAO pattern serialization and ORM were distilled from many years of experience they represent approaches that have stood the test of time. Unsurprisingly perhaps EJB entity beans have been a disaster in practice. Design flaws in the EJB specification prevent bean-managed persistence BMP entity beans from performing efficiently. A marginally more acceptable solution is container-managed persistence CMP at least since some glaring deficiencies of the EJB specification were rectified. Nevertheless CMP doesn t represent a solution to the object relational mismatch. Here are six reasons why CMP beans are defined in one-to-one correspondence to the tables of the relational model. Thus they re too coarse grained they may not take full advantage of Java s rich typing. In a sense CMP forces your domain model into first normal form. On the other hand CMP beans are also too fine grained to realize the stated goal of EJB the definition of reusable software components. A reusable component should be a very coarse-grained object with an external interface that is stable in the face of small changes to the database schema. Yes we really did just claim that CMP entity beans are both too fine grained and too coarse grained Although EJBs may take advantage of implementation inheritance entity beans don t support .