Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.
Articles
While it is not a good idea to use SQL-reserved keywords for database identifiers like table or column names, if you inherit a legacy schema that’s difficult to change, you will then have to escape the all database identifiers using SQL-reserved words. To achieve this goal, you can either use the JPA @Column
annotation or choose an automated globally escaping approach provided by Hibernate.
For more details, check out this article.
If you want to use Spring Boot with JPA and Hibernate, this article provides very detailed step-by-step instructions which will help you set up your project.
PostgreSQL provides a wide variety of database column types like JSON, ARRAY, INET or RANGE types.
The hibernate-types
open-source project aims to add support for all these types.
The 2.4.0 version comes with a PostgreSQLRangeType
which allows you to use any type of range that PostgreSQL supports (e.g. integer, number, date or timestamp).
For more details about using a PostgreSQL Range type with JPA and Hibernate, check out this article.
If you want to map a one-to-one association with JPA and Hibernate, this article demonstrates how you can achieve this goal.
When using JPA and Hibernate, the link table of a many-to-many table relationship is hidden at the entity modeling level, as only the parent sides need to be mapped. However, if you need to map extra columns, you need to map the link table as an entity so that Hibernate can persist any additional columns. This article explains how you can map a many-to-many relationship with extra columns when using JPA, Hibernate and Spring Boot.
Time to upgrade
The Hibernate ORM 5.4.1 version was released, so if you’re using the 5.4 branch, you should definitely upgrade to 5.4.1. For more details about the enhancements it brings, check out the release notes.
The Hibernate Search project has released two new versions: 5.11.1 and 6.0.0.Alpha2. For more details, check out this article.
Questions and answers
-
In a Hibernate SQL query, how do you escape the
?
character in the field name -
How to handle
@Lob
properties when using 2 different databases with Hibernate -
How to update a Hibernate entity when a column is updated externally
-
How to add a one-to-many association based on two columns where one has a FIXED VALUE
-
How to map a composite identifier using an automatically
@GeneratedValue
with JPA and Hibernate -
Why enabling the
hibernate.connection.autocommit
configuration is not recommended in Hibernate? -
Spring Boot with Hibernate generating drop constraint errors on startup with H2 database
-
Hibernate 5 Bytecode Enhancement Association Management works just in one direction
-
How to save data with a unique field in many-to-many relationship using JPA and Hibernate
-
How to inject multiple JPA EntityManager (persistence units) when using Spring