Chapter 4. Entity Basics
This chapter will look at entity beans as a means of accessing the Forethought application’s data storage. I’ll begin with simple entity beans to provide application entry points to the database, and address many questions common to entity bean development. Should you pass around the entity bean? Should you access the data exclusively through session beans, or directly through the entity beans? What are details objects, façade patterns, and good principles of entity bean design? All these questions will be answered, as I discuss not just writing EJB code, but writing effective EJB code.
At the end of this chapter, you will have the first entity bean created and deployed, ready for use. More importantly, you will have a good understanding of basic entity bean programming practices; you’ll have looked at using container-managed persistence, package and class naming, handling method exposure through the remote interface, and more. In other words, you’ll be ready for any basic entity bean problem that comes along, as well as for the advanced topics I’ll address in Chapter 5.
Basic Design Patterns
To access the data that will be stored in the database, you can use EJB’s entity bean functionality. Keep in mind, however, that this is not by any means a book on how to write Enterprise JavaBeans; for that I recommend Richard Monson-Haefel’s excellent book, Enterprise JavaBeans (O’Reilly). Here, I’ll simply focus on using EJBs correctly, and detail some useful design ...