How to map a String JPA property to a JSON column using Hibernate

Introduction In this article, I want to show you how you can map a String JPA property to a JSON database column using the hibernate-types open-source project. Although it’s probably more common to use a JsonNode or POJO (Plain Old Java Object) on the Java side, the hibernate-types framework is very flexible and allows you to use a String JPA property type to represent a JSON structure.

How to escape SQL reserved keywords with JPA and Hibernate

Introduction In this article, we are going to see how you can escape SQL reserved keywords with JPA and Hibernate. I decided to write this article because I keep on seeing this problem on the Hibernate forum or StackOverflow.

How to map a PostgreSQL Range column type with JPA and Hibernate

Introduction In this article, we are going to see how to map the PostgreSQL range column types with JPA and Hibernate. Luckily, you don’t have to implement a custom Hibernate type for the PostgreSQL range column type since the hibernate-types project already provides support for it.

How to get the current database transaction id

Introduction In this article, I’m going to show you how to get the current database transaction id. The transaction id is very useful for logging, especially if you want to correlate multiple log entries that are executed within the context of the same database transaction.

How to map a PostgreSQL HStore entity property with JPA and Hibernate

Introduction The open-source hibernate-types project allows you to map a great variety of database types that are not supported natively by Hibernate ORM (e.g. JSON, ARRAY, YearMonth, Month, INET addresses). In this article, we are going to see how you can map a PostgreSQL HStore type, which allows you to store key/value pairs, to a Java Map entity property when using JPA and Hibernate.

How to map a PostgreSQL Enum ARRAY to a JPA entity property using Hibernate

Introduction The open-source hibernate-types project allows you to map JSON, ARRAY, YearMonth, Month or database-specific columns (e.g. INET addresses). In this article, we are going to see how you can map a PostgreSQL Enum ARRAY type to a Java array entity property when using JPA and Hibernate.

How to bind custom Hibernate parameter types to JPA queries

Introduction In this article, we are going to see how we can bind a custom Hibernate parameter type to a JPA query. I decided to write this article after one of my hibernate-types framework users created this very interesting issue on GitHub.

How to intercept entity changes with Hibernate event listeners

Introduction In this article, we are going to see how the Hibernate event listeners work and how you add your custom listeners to intercept entity changes and replicate them to other database tables. Recently, one of my blog readers asked a very good question on StackOverflow. Since my main goal as a Hibernate Developer Advocate is to help Java developers get the most out of JPA and Hibernate, I decided that this is a good opportunity to talk about the Hibernate event listener mechanism.

The best way to initialize LAZY entity and collection proxies with JPA and Hibernate

Introduction In this article, we are going to see the best way to initialize LAZY proxies and collections when using JPA and Hibernate. I decided to write this article because there are way too many resources available on the Internet that mislead the reader into using awkward and inefficient practices.

Three years as a Hibernate Developer Advocate

Introduction Three years ago, I started working as a Developer Advocate for the Hibernate team at Red Hat. Each year, I write a new report to summarize the accomplishments for the Hibernate project and its community. If you’re curious about the previous year reports, check out the 2017 report – 2 years as a Hibernate Developer Advocate 2016 report – 1 year as a Hibernate Developer Advocate