Chapter 6. Spring Data

Data persistence and retrieval are inevitable operations in an enterprise world. The advent of JDBC paved the way to interact with multiple databases with ease and comfort. JDBC techlogies have gained popularity in no time because of their unified API to access any database, be it MySQL or Oracle or Sybase or any Relational Database System.

Spring took one step ahead and created an even lighter framework, abstracting the JDBC behind the scenes. Although the JDBC and Spring marriage makes a happy family, there are some unsophisticated or unavailable features from the joint venture. One feature that comes to mind is the support for Object Relational mappings. We still have to write plain old SQL statements to access the data from persistent stores. This is the opportunity Hibernate grabbed and became an instant hit! With millions of downloads over the time, it is now a popular and powerful open source framework. Spring added more abstraction on top of the already powerful Hibernate to make it even better.

This chapter explains how the Spring Framework can be used effectively for accessing databases, without even having to worry about connections and statements. We then continue on to Spring’s ORM support, using Hibernate.

JDBC and Hibernate

The joint venture did not attempt to bridge the gap between Objects and Relational Data. JDBC is certainly one of the first-hand choices for a Java developer when working with databases. JDBC abstracts away the intricacies involved ...

Get Just Spring 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.