Spring Persistence Tutorial

I usually post about Persistence on Twitter - you can follow me there:

This tutorial series focuses on doing Persistence with Spring – illustrating examples with Hibernate, JPA and Spring Data.

1. Core Persistence

Hibernate 3 with Spring

Setup Hibernate 3 with Spring – the Java and XML Configuration, integration with MySQL and usage best practices.

Hibernate 4 with Spring

Setup Hibernate 4 with Spring – the Java and XML Configuration, how to use and best practices.

JPA with Spring

Setup JPA with Spring – the Java and XML Configuration, the Maven dependencies and a generic DAO example.

Persistence with Spring Data JPA

Spring Data JPA with Spring – how to remove the DAO implementation, manual and automatic custom queries, transactions with Spring Data and configuration.


2. The DAO

The DAO with Spring and Hibernate

Implement a generic DAO with Hibernate in Spring.

The DAO with JPA and Spring

How to implement the DAO with JPA in a Spring project.

Simplify the DAO with Spring and Java Generics

How to simplify the Data Access Layer by using a single, generified DAO, which will result in elegant data access, with no unnecessary clutter.


3. Advanced Persistence

Transaction Configuration with Spring 4 and JPA

Transaction Configuration with Spring 4 and JPA – how to Enable and Configure Transactions and set up Transaction Propagation.

Hibernate Mapping Exception – Unknown Entity

Hibernate Mapping ExceptionUnknown Entity – causes and solutions.

Sorting with JPA

How to Sort in JPA using JQL or the Criteria API.

Sorting with Hibernate

Sort with Hibernate 4 using HQL or the Criteria API.

JPA Pagination

Pagination in JPA – how to use JQL and the Criteria API to do pagination correctly.

Hibernate Pagination

Pagination in Hibernate – using basic HQL, ScrollableResults as well as the more flexible and type-safe Criteria API.

Externalize Setup Data via CSV in a Spring Application

Learn how to use CSV files to hold the Setup data for a Spring web application, and how to fully load and persist that data from disk.

Use Liquibase to Safely Evolve Your Database Schema

How to use Liquibase to safely and maturely evolve the database schema of your Java app.


4. Spring Data MongoDB

Introduction to Spring Data MongoDB

A solid intro to using MongoDB in with Spring Data.

A Guide to Queries in Spring Data MongoDB

How to Query MongoDB with Spring Data: Query and Criteria, auto-generated repository methods, raw queries with the @Query annotation as well as QueryDSL.

Spring Data MongoDB – Indexes, Annotations and Converters

How to work with Indexes, Converters and Common Annotations in Spring Data MongoDB.

Custom Cascading in Spring Data MongoDB

How to implement a solid, generic cascading mechanism with lifecycle events in Spring Data MongoDB.

Other Spring Tutorials


The entire tutorial in based on this github project. Watch and fork it at will – the project can be used as a starting point for a more full fledged implementation.

I usually post about Persistence on Twitter - you can follow me there:

, ,

  • _madFrog

    Thank you so much for putting it all up at once place.

  • Gaurav Dighe

    Hello, Can you plz publish pdf for Spring4 with Spring-Data-JPA.