How to synchronize bidirectional entity associations with JPA and Hibernate

Introduction

While answering this StackOverflow question, I realized that it’s a good idea to summarize how various bidirectional associations should be synchronized when using JPA and Hibernate.

Therefore, in this article, you are going to learn how and also why you should always synchronize both sides of an entity relationship, no matter if it’s @OneToMany, @OneToOne or @ManyToMany.

Continue reading “How to synchronize bidirectional entity associations with JPA and Hibernate”

How to use @PrePersist and @PreUpdate on Embeddable with JPA and Hibernate

Introduction

In a previous article, I explained how you could audit entity modifications using the JPA @EntityListeners for embeddable types.

Since Hibernate ORM 5.2.17 now allows you to use the @PrePersist and @PreUpdate JPA entity listeners, we can simplify the previous example, as you will see in this article.

Continue reading “How to use @PrePersist and @PreUpdate on Embeddable with JPA and Hibernate”

9 High-Performance Tips when using PostgreSQL with JPA and Hibernate

Introduction

To get the most out of the relational database in use, you need to make sure the data access layer resonates with the underlying database system.

In this article, we are going to see what you can do to boost up performance when using PostgreSQL with JPA and Hibernate.

Continue reading “9 High-Performance Tips when using PostgreSQL with JPA and Hibernate”