Chapter 3. Spring Persistence Using JPA

Up until now, we haven't looked at the need for applications to store and preserve data. Many applications must store data beyond the application's own lifetime. In fact, some business applications are created specifically to store, retrieve, and modify data. It is very important to understand how Spring can help in creating these applications.

The storage of data, in object-oriented systems, is called persistence. When a data object is saved to a database, the object has been persisted. Of course, you can persist your data objects to disk using your own custom-written code, perhaps calling a database's published API. But when you use modern frameworks, such as Spring, there is often built-in support to make object persistence simple.

In the world of enterprise software development, component persistence is synonymous with entity Enterprise Java Beans (EJBs). Entity EJBs are business data components that can be automatically stored into and retrieved from a variety of relational databases. Unfortunately, you need to pay a hefty price for automated EJB persistence support: you must run a large server called the Java EE EJB container.

The "heavyweight server" requirement was such a widespread industry problem that in June 2003 a JSR 220 expert group was chartered in order to simplify EJB container-managed persistence (CMP). The expert group decided that a simplification of EJB CMP was not sufficient, and that what was needed was a lightweight framework ...

Get Beginning Spring Framework 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.