14 Integrating JPA and Hibernate with Spring
This chapter covers
- Overviewing Spring Framework and Dependency Injection
- Examining the Data Access Object (DAO) design pattern
- Creating and generifying a Spring JPA application using the DAO design pattern
- Creating and generifying a Spring Hibernate application using the DAO design pattern
In this chapter, we analyze a few different possibilities to integrate Spring and Hibernate. Spring is a lightweight but also flexible and universal Java framework. It is open-source and it can be used at the level of any layer in a Java application. We’ll investigate the principles at the ground of the Spring framework (the dependency injection, also known as inversion of control) and we’ll use Spring together with JPA or Hibernate to build Java persistence applications.
To be able to execute the examples from the source code, you need first to run the Ch14.sql script.
14.1 Spring Framework and Dependency Injection Overview
The Spring Framework provides a comprehensive infrastructure for developing Java applications. It handles the infrastructure so that you can focus on your application and enables you to build applications from plain old Java objects (POJOs).
Rod Johnson created Spring in 2002, beginning with his book Expert One-on-One J2EE Design and Development. The basic idea behind Spring is to simplify the traditional approach to designing enterprise applications.