Vlad Mihalcea

A beginner’s guide to Hibernate Statistics

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. Hypersistence Optimizer is that tool!

Introduction

Hibernate provides a very powerful Statistics mechanism that, unfortunately, is lesser known. In this article, we are going to see how the Hibernate Statistics mechanism works, and how you can activate.

While the Hibernate Statistics mechanism is not enabled by default, you will see that many applications can benefit from using it, especially when it comes to determining cache effectiveness.

Read More

A beginner’s guide to database table relationships

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. Hypersistence Optimizer is that tool!

Introduction

In a relational database, a relationship is formed by correlating rows belonging to different tables. A table relationship is established when a child table defines a Foreign Key column that references the Primary Key column of its parent table.

Every database table relationship is, therefore, built on top of Foreign Key columns, and there can be three table relationship types:

  • one-to-many is the most common relationship, and it associates a row from a parent table to multiple rows in a child table.
  • one-to-one requires the child table Primary Key to be associated via a Foreign Key with the parent table Primary Key column.
  • many-to-many requires a link table containing two Foreign Key columns that reference the two different parent tables.

In this article, we are going to describe all these three table relationships as well as their use cases.

Read More

How to implement a database job queue using SKIP LOCKED

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. Hypersistence Optimizer is that tool!

Introduction

In this article, we are going to see how we can implement a database job queue using SKIP LOCKED.

I decided to write this article while answering this Stack Overflow question asked by Rafael Winterhalter.

Since SKIP LOCKED is a lesser-known SQL feature, it’s a good opportunity to show you how to use it and why you should employ it, especially when implementing a job queue task.

Read More

How to change the @OneToOne shared primary key column name with JPA and Hibernate

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. Hypersistence Optimizer is that tool!

Introduction

In this article, we are going to see how you can change the @OneToOne shared primary key column name when using JPA and Hibernate. This has been a recurrent theme when answering questions about Hibernate or during my High-Performance Java Persistence training.

As previously explained, the one-to-one database table relationship requires the Primary Key to be shared among the parent and the child tables.

Unfortunately, just adding the JPA @OneToOne annotation in the child entity does not render a true one-to-one table relationship since a separate Foreign Key column will be used. Only when adding the @MapsId annotation will the JPA one-to-one association map to a real one-to-one table relationship.

Read More

How does a relational database execute SQL statements and prepared statements

Imagine having a tool that can automatically detect if you are using JPA and Hibernate properly. Hypersistence Optimizer is that tool!

Introduction

In this article, we are going to see how a relational database executes SQL statements and prepared statements.

Read More

Want to run your data access layer at warp speed?