O'Reilly logo

Enterprise JavaBeans™ Component Architecture: Designing and Coding Enterprise Applications by Paul Anderson, Gail Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.6. Design Guidelines and Patterns

We have added a level of complexity to the example in this chapter by including an Enterprise Java Bean that accesses a database. The Music EJB can be a stateless session bean because it accesses the database in a read-only capacity.

DAO Pattern

Our first implementation keeps things as simple as possible by implementing database calls as private methods inside the bean implementation code. The trade-off between simplicity and lack of flexibility means that our code is “hard wired” to access a particular vendor's database. The second version uses the Data Access Object (DAO) Pattern to solve this lack of flexibility. Our approach is to create an interface that the bean implementation code invokes, and to write ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required