In this chapter
- Integrating JPA with CDI and JSF
- Browsing data in tables
- Implementing long-running conversations
- Customizing entity serialization
In this chapter, you see how Hibernate works in a typical web application environment. There are dozens of web application frameworks for Java, so we apologize if we don’t cover your favorite combination here. We discuss JPA in the standard Java Enterprise Edition environment, in particular combined with standards Contexts and Dependency Injection (CDI), JavaServer Faces (JSF), and Java API for RESTful web services (JAX-RS). As always, we show patterns you can apply in other proprietary environments.
First we revisit the persistence layer and introduce CDI management for the DAO classes. Then we extend these classes with a generic solution for sorting and paging data. This solution is useful whenever you have to display data in tables, no matter what framework you choose.
Next, you write a fully functional JSF application on top of the persistence layer and look at the Java EE conversation scope, where CDI and JSF work together to provide a simple stateful model for server-side components. If you didn’t like the stateful EJBs with the extended persistence context in the last chapter, maybe these conversation examples with detached entity state on the server are what you’re looking for.