Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

13.2. Seam CRUD DAOs Are POJOs

Because the DAO is responsible for only data access and does not need any other EJB3 container services, we should be able to use Seam POJOs instead of EJB3 session beans (see Section 2.4.1., “Seam POJO Components”). The benefit of Seam POJOs is that they are simpler than EJB3 session beans and can deploy in older J2EE 1.4 application servers, but they do need a little extra configuration (see Chapter 24, Seam Without EJB3). If you use Seam Gen (Chapter 4, Rapid Application Development Tools) to generate your configuration files, the POJO settings are enabled by default. If you write your own configuration files from the Hello World examples, you need to pay attention to a couple places. The idea here is to bootstrap a Seam-managed EntityManager for the DAO POJOs because the POJOs cannot directly use the EJB3-managed EntityManager.

First, in the faces-config.xml file in app.war/WEB-INF, you need to use the TransactionalSeamPhaseListener instead of the standard SeamPhaseListener used in typical Seam EJB3 applications. The TransactionalSeamPhaseListener provides a Seam-managed transaction manager for the EntityManager.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint