Flyway Database Schema Migrations

Introduction In this article, I’m going to explain how Flyway works and how you can use it to run automated database schema migrations using incremental SQL migration scripts. Flyway is an open-source project created by Axel Fontaine and later acquired by Red Gate. The database migrations can be defined either as SQL scripts or JDBC-based classes.

Java Map to JSON mapping with JPA and Hibernate

Introduction In this article, we are going to see how we can store Java Map entity attributes in JSON columns when using JPA, Hibernate, and the Hibernate Types project. While you can also persist Java Map entity attributes in PostgreSQL HStore columns, a JSON column type is a much more common option, especially since it works with other relational databases, like Oracle, SQL Server, or MySQL. As you already have seen, the Hibernate Types project allows you to map a JSON column type to a wide variety of JPA entity attributes, like… Read More

High-Performance Java Persistence Newsletter, Issue 12

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.

Read-write and read-only transaction routing with Spring

Introduction In this article, I’m going to explain how you can implement a read-write and read-only transaction routing mechanism using the Spring framework. This requirement is very useful since the Single-Primary Database Replication architecture not only provides fault-tolerance and better availability, but it allows us to scale read operations by adding more replica nodes.

JPA and Hibernate Query setParameter – User Guide

Introduction In this article, I’m going to show you how the JPA Query setParameter method works for basic entity attributes, and how you can use it when dealing with custom Hibernate types. If you ever stumbled on the “column is of type jsonb but expression is of type bytea” PostgreSQL issue and didn’t know how to fix it, then you should definitely read this article.

High-Performance Java Persistence Newsletter, Issue 11

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.

How to get the SQL query from JPQL or JPA Criteria

Introduction In this article, I’m going to show you how you can get the auto-generated SQL query from a JPQL or JPA Criteria API entity query.