The Baeldung logo
  • The Baeldung Logo
  • Start Here
  • Courses ▼▲
    • REST with Spring

      The canonical reference for building a production grade API with Spring

    • Learn Spring Security ▼▲

      THE unique Spring Security education if you’re working with Java today

      • Learn Spring Security Core

        Focus on the Core of Spring Security 5

      • Learn Spring Security OAuth

        Focus on the new OAuth2 stack in Spring Security 5

    • Learn Spring

      From no experience to actually building stuff​

    • Learn Spring Data JPA

      The full guide to persistence with Spring Data JPA

  • Guides ▼▲
    • Persistence

      The Persistence with Spring guides

    • REST

      The guides on building REST APIs with Spring

    • Security

      The Spring Security guides

  • About ▼▲
    • Full Archive

      The high level overview of all the articles on the site.

    • Baeldung Ebooks

      Discover all of our eBooks

    • About Baeldung

      About Baeldung.

Persistence

The persistence layer is vital to almost any application. Have a look at different ways to implement persistence in Java.

  • JPA (94)
  • Hibernate (85)
  • Mongodb (55)
  • SQL (40)
  • Spring Data JPA (39)
  • JDBC (28)
  • Cassandra (24)
  • Redis (12)
  • Couchbase (10)
  • Elasticsearch (10)
  • Transactions (9)
  • Spring Data REST (7)

>> Introduction to ScyllaDB with Java

>> Differences Between Spring Data JPA findFirst() and findTop()

>> Flyway Out of Order Migrations

>> Difference Between JPA and Spring Data JPA

>> NonUniqueResultException in Spring Data JPA

>> Getting Started with Blaze Persistence

>> MongoDB vs. Couchbase

>> How to Serialize a Singleton in Java

>> Persisting the Query Model

>> Generate Unique ObjectId in MongoDB

>> Guide to Filters in MongoDB

>> How to Insert a HashMap Into MongoDB With Java?

>> Redis Sentinel vs Clustering

>> Patterns for Iterating Over Large Result Sets With Spring Data JPA

>> Insert Array Inside an Object in MongoDB

>> Guide to the Storage Engine in Apache Cassandra

>> Guide to MicroStream

>> Connect to Multiple Databases Using Spring Data MongoDB

>> Multitenancy With Spring Data JPA

>> Spring JDBC Batch Inserts

>> What Causes “Lock wait timeout exceeded” Error in MySQL?

>> Spring Data MongoDB – Configure Connection

>> Count Documents Using Spring Data MongoDB Repository

>> Query Documents using Document ID in MongoDB

>> Spring Data Rest – Serializing the Entity ID

>> Using Dates in CRUD Operations in MongoDB

>> UUID as Entity ID in MongoDB

>> Unique Field in MongoDB Document in Spring Data

>> Guide to Find in MongoDB

>> Hibernate’s “Detached Entity Passed to Persist” Error

>> MongoDB Composite Key With Spring Data

>> Spring Data JPA – Run an App Without a Database

>> Tomcat Warning “To Prevent a Memory Leak, the JDBC Driver Has Been Forcibly Unregistered”

>> Using Transactions for Read-Only Operations

>> Configure MongoDB Collection Name for a Class in Spring Data

>> Joining Tables With Spring Data JPA Specifications

>> Converting a JDBC ResultSet to JSON in Java

>> JPA and Hibernate – Criteria vs. JPQL vs. HQL Query

>> Checking Connection to MongoDB

>> Hibernate’s “Not-Null Property References a Null or Transient Value” Error

>> Liquibase vs Flyway

>> Distinct Queries in HQL

>> Return Only Specific Fields for a Query in Spring Data MongoDB

>> BootstrapMode for JPA Repositories

>> A Guide to JPA Buddy

>> Retrieve a Value from MongoDB by Its Key Name

>> Bulk Update of Documents in MongoDB

>> Guide to Upsert in MongoDB

>> Logging MongoDB Queries with Spring Boot

>> Import Data to MongoDB From JSON File Using Java

>> Get the Number of Rows in a ResultSet

>> A Guide to @DBRef in MongoDB

>> Push Operations in MongoDB

>> Push and Set Operations in Same MongoDB Update

>> Case Insensitive Sorting in MongoDB

>> Authentication With Spring Security and MongoDB

>> Secondary Indexes in Cassandra

>> Check Collection Existence in MongoDB

>> Update Documents in MongoDB

>> Update Multiple Fields in a MongoDB Document

>> Building a web app Using Fauna and Spring for Your First web Agency Client

>> Connecting to a NoSQL Database with Spring Boot

>> Hibernate’s addScalar() Method

>> Configure and Use Multiple DataSources in Spring Boot

>> JDBC Connection Status

>> Hibernate Validator Annotation Processor in Depth

>> Get Last Inserted Document ID in MongoDB With Java Driver

>> Cassandra Query Cheat Sheet

>> How to Access EntityManager with Spring Data

>> Introduction to FaunaDB with Spring

>> Replication Strategies and Partitioning in Cassandra

>> Is Cassandra a Column-Oriented or Column-Family Database?

>> Logging Queries with Spring Data Cassandra

>> Getting Started With Apache Derby

>> Using Test Containers With Spring Data Cassandra

>> Saving Date Values in Spring Data Cassandra

>> Cassandra Frozen Keyword

>> Hibernate’s “Object References an Unsaved Transient Instance” Error

>> Build a Dashboard With Cassandra, Astra and CQL – Mapping Event Data

>> Consistency Levels in Cassandra

>> Connecting to a Specific Schema in JDBC

>> How to Check Field Existence in MongoDB?

>> Cassandra Partition Key, Composite Key, and Clustering Key

>> Spring Data with ArangoDB

>> A Guide to Auto-Commit in JDBC

>> EntityNotFoundException in Hibernate

>> CQL Data Types

>> Is java.sql.Connection Thread-Safe?

>> JPA Entities and the Serializable Interface

>> Cluster, Datacenters, Racks and Nodes in Cassandra

>> Build a Dashboard With Cassandra, Astra, REST & GraphQL – Recording Status Updates

>> A Comparison Between JPA and JDBC

>> JPA Support – State of the Tools Ecosystem in 2021

>> Inserting Null Into an Integer Column Using JDBC

>> Defining Unique Constraints in JPA

>> How to Return Multiple Entities In JPA Query

>> Build a Dashboard Using Cassandra, Astra, and Stargate

>> How to Implement a Soft Delete with Spring JPA

>> Overriding Column Definition With @AttributeOverride

>> Returning an Auto-Generated Id with JPA

>> Mapping PostgreSQL Array With Hibernate

>> Spring Boot Cache with Redis

>> How to Deal With Databases in Docker?

>> Usage of the Hibernate @LazyCollection Annotation

>> Count Query In jOOQ

>> How to Check if a Database Table Exists with JDBC

>> Creating a Read-Only Repository with Spring Data

>> How to Convert a Hibernate Proxy to a Real Entity Object

>> Learn JPA & Hibernate

>> Redis vs MongoDB

>> JDBC URL Format For Different Databases

>> A Guide to MultipleBagFetchException in Hibernate

>> Running Spring Boot with PostgreSQL in Docker Compose

>> Performance Difference Between save() and saveAll() in Spring Data

>> Defining Indexes in JPA

>> JPA CascadeType.REMOVE vs orphanRemoval

>> Ignoring Fields With the JPA @Transient Annotation

>> Storing Files Indexed by a Database

>> Object States in Hibernate’s Session

>> Apache Spark: Differences between Dataframes, Datasets and RDDs

>> Getting Database URL From JDBC Connection Object

>> Where Does H2’s Embedded Database Store The Data?

>> Performing Calculations in the Database vs. the Application

>> Getting Started with jOOQ

>> How to Implement Hibernate in an AWS Lambda Function in Java

>> DAO vs Repository Patterns

>> Rolling Back Migrations with Flyway

>> What Is the Hi/Lo Algorithm?

>> Introduction to Spring Data Azure Cosmos DB

>> Extracting Database Metadata Using JDBC

>> JPA Entity Equality

>> Introduction to Spring Data JDBC

>> Flyway Repair With Spring Boot

>> Difference Between Statement and PreparedStatement

>> Loading JDBC Drivers

>> Test a Mock JNDI Datasource with Spring

>> Injecting Spring Beans into Unmanaged Objects

>> Testing @Cacheable on Spring Data Repositories

>> Returning the Generated Keys in JDBC

>> When Does JPA Set the Primary Key

>> Hibernate could not initialize proxy – no Session

>> Partial Data Update With Spring Data

>> A Guide to the Hibernate Types Library

>> Transactional Annotations: Spring vs. JTA

>> Spring Data Redis’s Property-Based Configuration

>> Generate Database Schema with Spring Data JPA

>> Spring JPA @Embedded and @EmbeddedId

>> Memcached vs Redis

>> Constructing a JPA Query Between Unrelated Entities

>> Using a List of Values in a JdbcTemplate IN Clause

>> Oracle Connection Pooling With Spring

>> Hibernate Error “No Persistence Provider for EntityManager”

>> BSON to JSON Document Conversion in Java

>> Custom Naming Convention with Spring Data JPA

>> Quick Guide to EntityManager#getReference()

>> Spring JdbcTemplate Unit Testing

>> Quick Guide to Hibernate enable_lazy_load_no_trans Property

>> Delete Everything in Redis

>> Connect Java to a MySQL Database

>> Calling Stored Procedures from Spring Data JPA Repositories

>> List All Redis Databases

>> MongoDB Aggregations Using Java

>> JPA Entity Lifecycle Events

>> Working with Lazy Element Collections in JPA

>> List All Available Redis Keys

>> Various Logging Levels in Hibernate

>> Hibernate @NotNull vs @Column(nullable = false)

>> JPA/Hibernate Persistence Context

>> FetchMode in Hibernate

>> Hibernate Error “Not all named parameters have been set”

>> Customizing the Result of JPA Queries with Aggregation Functions

>> Mapping a Single Entity to Multiple Tables in JPA

>> Intro to Spring Data Geode

>> Programmatic Transaction Management in Spring

>> JPA Annotation for the PostgreSQL TEXT Type

>> Transaction Propagation and Isolation in Spring @Transactional

>> Transaction Support in Spring Integration

>> Hibernate @WhereJoinTable Annotation

>> Using JaVers for Data Model Auditing in Spring Data

>> Using JDBI with Spring Boot

>> Repositories with Multiple Spring Data Modules

>> Spring Data Reactive Repositories with Couchbase

>> Intro to DataStax Java Driver for Apache Cassandra

>> JPA Query Parameters Usage

>> A Guide to SirixDB

>> MyBatis with Spring

>> Spring Security: Exploring JDBC Authentication

>> Mapping Entity Class Names to SQL Table Names with JPA

>> A Guide to the sql2o JDBC Wrapper

>> R2DBC – Reactive Relational Database Connectivity

>> @DynamicUpdate with Spring Data JPA

>> Introduction to Morphia – Java ODM for MongoDB

>> A Quick Look at R2DBC with Spring Data

>> Upload and Retrieve Files Using MongoDB and Spring Boot

>> Disable Spring Data Auto Configuration

>> Guide to MapDB

>> Setting the MySQL JDBC Timezone Using Spring Boot Configuration

>> Spring Data MongoDB Tailable Cursors

>> Overview of JPA/Hibernate Cascade Types

>> Jest – Elasticsearch Java Client

>> Spring Session with MongoDB

>> Geospatial Support in MongoDB

>> Enabling Transaction Locks in Spring Data JPA

>> Double Dispatch in DDD

>> Composite Primary Keys in JPA

>> Intro to OData with Olingo

>> JPA/Hibernate Projections

>> Persisting Enums in JPA

>> LIKE Queries in Spring JPA Repositories

>> Derived Query Methods in Spring Data JPA Repositories

>> OData Protocol Guide

>> JPA @Basic Annotation

>> Default Column Values in JPA

>> Defining JPA Entities

>> Batch Insert/Update with Hibernate/JPA

>> Spring Data JPA and Named Entity Graphs

>> Difference Between @Size, @Length, and @Column(length=value)

>> MongoDB BSON Guide

>> Spring Data JPA Delete and Relationships

>> Spring Data JPA Repository Populators

>> Types of SQL Joins

>> Persisting Maps with Hibernate

>> Spring Data Web Support

>> Spring Boot With H2 Database

>> Spring Data JPA and Null Parameters

>> JPA @Embedded And @Embeddable

>> JPA Join Types

>> Case Insensitive Queries with Spring Data Repository

>> Types of JPA Queries

>> The Exists Query in Spring Data

>> Difference Between save() and saveAndFlush() in Spring Data JPA

>> Spring Data JPA – Derived Delete Methods

>> TransactionRequiredException Error

>> Spring Boot with Hibernate

>> Resolving “Failed to Configure a DataSource” Error

>> Guide to the JDBC ResultSet Interface

>> Combining JPA And/Or Criteria Predicates

>> Spring Data JPA Batch Inserts

>> Spring Data JPA @Modifying Annotation

>> SQL Injection and How to Prevent It?

>> DB Integration Tests with Spring Boot and Testcontainers

>> Hibernate Query Plan Cache

>> Hibernate Aggregate Functions

>> Spring Data JPA Query by Example

>> Configuring a DataSource Programmatically in Spring Boot

>> Common Hibernate Exceptions

>> JPA 2.2 Support for Java 8 Date/Time Types

>> Building a Data Pipeline with Kafka, Spark Streaming and Cassandra

>> INSERT Statement in JPA

>> Integrating Spring Boot with HSQLDB

>> Criteria Queries Using JPA Metamodel

>> Hibernate 5 Bootstrapping API

>> Persist a JSON Object Using Hibernate

>> A Guide to Hibernate OGM

>> Pagination and Sorting using Spring Data JPA

>> Using c3p0 with Hibernate

>> Guide to the Hibernate EntityManager

>> Hibernate Named Query

>> One-to-One Relationship in JPA

>> Spring Boot With SQLite

>> JPA Entity Graph

>> Get All Data from a Table with Hibernate

>> Auto-Generated Field for MongoDB using Spring Boot

>> Spring Data with Reactive Cassandra

>> Sorting Query Results with Spring Data

>> The Difference Between JPA, Hibernate and EclipseLink

>> Difference Between @JoinColumn and mappedBy

>> Fixing the JPA error “java.lang.String cannot be cast to Ljava.lang.String;”

>> Criteria API – An Example of IN Expressions

>> Customizing HTTP Endpoints in Spring Data REST

>> Many-To-Many Relationship in JPA

>> Persisting DDD Aggregates

>> ZonedDateTime with Spring Data MongoDB

>> Limiting Query Results with JPA and Spring Data JPA

>> Hibernate Field Naming with Spring Boot

>> Custom Types in Hibernate and the @Type Annotation

>> An Introduction to Spring Data Redis Reactive

>> Guide to Ebean ORM

>> Spring Data MongoDB Transactions

>> Proxy in Hibernate load() Method

>> CDI Portable Extension and Flyway

>> A Quick Guide to Apache Geode

>> Netflix Archaius with Various Database Configurations

>> Spring Persistence Tutorial

>> Access the Same In-Memory H2 Database in Multiple Spring Boot Applications

>> Hibernate 5 Naming Strategy Configuration

>> Mapping A Hibernate Query to a Custom Class

>> Spring Data – CrudRepository save() Method

>> Guide to Jakarta EE JTA

>> DDD Aggregates and @DomainEvents

>> Configuring a Tomcat Connection Pool in Spring Boot

>> @JoinColumn Annotation Explained

>> Use Criteria Queries in a Spring Data Application

>> Guide to Lucene Analyzers

>> Configuring a Hikari Connection Pool with Spring Boot

>> Hibernate Entity Lifecycle

>> Spring Data Composable Repositories

>> Introduction to Hazelcast Jet

>> A Simple Guide to Connection Pooling in Java

>> Spring Session with JDBC

>> A Guide to SqlResultSetMapping

>> Query Entities by Dates and Times with Spring Data JPA

>> A Guide to Eclipse JNoSQL

>> Spring Boot Integration Testing with Embedded MongoDB

>> Spring Boot with Multiple SQL Import Files

>> Spring AMQP in Reactive Applications

>> The DAO Pattern in Java

>> Optimistic Locking in JPA

>> A Guide to DeltaSpike Data Module

>> Bootstrapping JPA Programmatically in Java

>> Spring Data Reactive Repositories with MongoDB

>> A Guide to Spring Data Key Value

>> Spring Data REST Events with @RepositoryEventHandler

>> Spring Data Annotations

>> Pessimistic Locking in JPA

>> Spring Data JPA @Query

>> Projections and Excerpts in Spring Data REST

>> Apache Ignite with Spring Data

>> A Guide to Apache Ignite

>> Obtaining Auto-generated Keys in Spring JDBC

>> Show Hibernate/JPA SQL Statements from Spring Boot

>> Integration Testing with a Local DynamoDB Instance

>> A Simple Tagging Implementation with MongoDB

>> Mapping LOB Data in Hibernate

>> Spring Data with Spring Security

>> A Guide to Jdbi

>> An Advanced Tagging Implementation with JPA

>> JDBC with Groovy

>> A Guide to Infinispan in Java

>> A Simple Tagging Implementation with JPA

>> Introduction to ActiveJDBC

>> Introduction to Jinq with Spring

>> JPA Attribute Converters

>> A Simple Tagging Implementation with Elasticsearch

>> Programmatic Transactions in the Spring TestContext Framework

>> Introduction to Lettuce – the Java Redis Client

>> Geospatial Support in ElasticSearch

>> Guide to CockroachDB in Java

>> A Guide to Multitenancy in Hibernate 5

>> Bootstrapping Hibernate 5 with Spring

>> Spring Data Java 8 Support

>> Introduction to the OrientDB Java APIs

>> A Guide to Flyway Callbacks

>> Hibernate Interceptors

>> Using InfluxDB with Java

>> A Simple File Search with Lucene

>> A Guide to EclipseLink with Spring

>> Batch Processing in JDBC

>> Introduction to Apache Lucene

>> Introduction to Hibernate Spatial

>> Send Operating System Data into Elastic Stack (ELK Stack)

>> Introduction to Hibernate Search

>> Introduction to the JDBC RowSet Interface in Java

>> Hibernate Inheritance Mapping

>> Quick Guide on Loading Initial Data with Spring Boot

>> Send the Logs of a Java App to the Elastic Stack (ELK)

>> A Guide to Spring AbstractRoutingDatasource

>> JMX Data to the Elastic Stack (ELK)

>> An Overview of Identifiers in Hibernate/JPA

>> Hibernate – Mapping Date and Time

>> HibernateException: No Hibernate Session Bound to Thread in Hibernate 3

>> Dynamic Mapping with Hibernate

>> Intro to JDO Queries 2/2

>> Spring Data JPA – Adding a Method in All Repositories

>> Advanced Querying in Apache Cayenne

>> Introduction to ORMLite

>> Introduction to Apache Cayenne ORM

>> Querying Couchbase with N1QL

>> Introduction to rxjava-jdbc

>> CrudRepository, JpaRepository, and PagingAndSortingRepository in Spring Data

>> Hibernate Many to Many Annotation Tutorial

>> Introduction to Reladomo

>> Guide to Spring Data LDAP

>> Data Modeling in Cassandra

>> Vavr Support in Spring Data

>> A Guide to Apache Commons DbUtils

>> Introduction to Liquibase Rollback

>> Introduction to HikariCP

>> Guide to Java Data Objects

>> Introduction to JDBC

>> Quick Guide to MyBatis

>> Dynamic DTO Validation Config Retrieved from the Database

>> Configuring Separate Spring DataSource for Tests

>> Hibernate Tips Book Excerpt: How to Map an Inheritance Hierarchy to One Table

>> List of In-Memory Databases

>> A Guide to GemFire with Spring Data

>> Self-Contained Testing Using an In-Memory Database

>> Full-text Search with Solr

>> Intro to Apache Kafka with Spring

>> A Guide to Redis with Redisson

>> @Immutable in Hibernate

>> HBase with Java

>> AngularJS CRUD Application with Spring Data REST

>> Guide To Solr in Java With Apache SolrJ

>> Working with Relationships in Spring Data REST

>> AWS Lambda Using DynamoDB With Java

>> A Guide to Neo4J with Java

>> Quick Intro to Full-Text Search with ElasticSearch

>> Hibernate One to Many Annotation Tutorial

>> Querying Couchbase with MapReduce Views

>> Spring Data MongoDB: Projections and Aggregations

>> A Guide to MongoDB with Java

>> Deleting Objects with Hibernate

>> Introduction to Spring Data Solr

>> DynamoDB in a Spring Boot Application Using Spring Data

>> Introduction To Ehcache

>> A Guide to Cassandra with Java

>> Database Migrations with Flyway

>> Guide to Elasticsearch in Java

>> Guide to Spring Data REST Validators

>> Spring, Hibernate and a JNDI Datasource

>> Eager/Lazy Loading In Hibernate

>> Guide To Running Logic on Startup in Spring

>> Hibernate Second-Level Cache

>> JPA Criteria Queries

>> Asynchronous Batch Operations in Couchbase

>> 3 Common Hibernate Performance Issues and How to Find Them in Your Log File

>> Using Couchbase in a Spring Application

>> Intro to Jedis – the Java Redis Client Library

>> Hibernate: save, persist, update, merge, saveOrUpdate

>> Stored Procedures with Hibernate

>> Intro to Querydsl

>> Introduction to Couchbase SDK for Java

>> Introduction to Spring Data Neo4j

>> Spring Boot Support for jOOQ

>> Multiple Buckets and Spatial View Queries in Spring Data Couchbase

>> Entity Validation, Optimistic Locking, and Query Consistency in Spring Data Couchbase

>> Introduction to Jooq with Spring

>> Elasticsearch Queries with Spring Data

>> PubSub Messaging with Spring Data Redis

>> Introduction to Spring Data REST

>> Intro to Spring Data Couchbase

>> A Guide to Stored Procedures with JPA

>> A Guide to Querydsl with JPA

>> Protected: Spring Persistence (Hibernate and JPA) with a JNDI datasource

>> All Spring Data Guides

>> Introduction to Spring Data Elasticsearch

>> Introduction to Spring Data Redis

>> Auditing with JPA, Hibernate, and Spring Data JPA

>> Using the CassandraTemplate from Spring Data

>> An Introduction to Grails 3 and GORM

>> Simplify the DAO with Spring and Java Generics

>> Introduction to Spring Data Cassandra

>> Spring Data MongoDB Tutorial

>> REST Query Language with Querydsl Web Support

>> GridFS in Spring Data MongoDB

>> A Spring Custom Annotation for a Better DAO

>> Custom Cascading in Spring Data MongoDB

>> Spring Data MongoDB – Indexes, Annotations and Converters

>> A Guide to Queries in Spring Data MongoDB

>> Use Liquibase to Safely Evolve Your Database Schema

>> Externalize Setup Data via CSV in a Spring Application

>> Introduction to Spring Data MongoDB

>> REST Query Language with RSQL

>> REST Query Language – Advanced Search Operations

>> Spring JPA – Multiple Databases

>> REST Query Language with Spring Data JPA and Querydsl

>> REST Query Language with Spring Data JPA Specifications

>> Spring JDBC

>> Transactions with Spring and JPA

>> Introduction to Spring Data JPA

>> Sorting with Hibernate

>> Sorting with JPA

>> Hibernate Pagination

>> JPA Pagination

>> A Guide to JPA with Spring

>> The DAO with JPA and Spring

>> Hibernate Mapping Exception – Unknown Entity

>> Spring DataIntegrityViolationException

>> Hibernate 3 with Spring

>> The DAO with Spring and Hibernate

  • ↑ Back to Top
res – Persistence (eBook) (cat=Persistence)
opt-in
Download the E-book
The Baeldung logo

Courses

  • All Courses
  • All Bulk Courses
  • All Bulk Team Courses
  • The Courses Platform

Series

  • Java “Back to Basics” Tutorial
  • Jackson JSON Tutorial
  • Apache HttpClient Tutorial
  • REST with Spring Tutorial
  • Spring Persistence Tutorial
  • Security with Spring
  • Spring Reactive Tutorials

About

  • About Baeldung
  • The Full Archive
  • Editors
  • Jobs
  • Our Partners
  • Partner with Baeldung
  • Terms of Service
  • Privacy Policy
  • Company Info
  • Contact
The Baeldung Logo