1 Understanding object/relational persistence
This chapter covers
- Persisting with SQL databases in Java applications
- Analyzing the object/relational paradigm mismatch
- Introducing ORM, JPA, Hibernate, and Spring Data
Working with Java means in most cases working with objects, as the central figure of object-oriented programs. While the program is executed, it may create and manage in-memory objects, but they are getting lost when it comes to the end. Frequently, at least some part of the information they contain will be needed after a while. Saving this information means to persist it prior to stopping the execution of the program.
When an object is instantiated running an application, it becomes transient – its existence happens only inside that application. Persisting an object means making it available for the long term, even if the program terminated or stopped.
This book is about JPA, Hibernate, and Spring Data; our focus is on using Hibernate as a provider of the Jakarta Persistence API (formerly Java Persistence API) and Spring Data as a Spring-based programming model for data access. We cover basic and advanced features and describe some ways to develop new applications using Java Persistence. Often, these recommendations aren’t specific to Hibernate or Spring Data. Sometimes they’re our own ideas about the best ways to do things when working with persistent data, explained in the context of Hibernate and Spring Data.