Vlad Mihalcea

How does the 2PL (Two-Phase Locking) algorithm work

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

Introduction

The 2PL (Two-Phase Locking) algorithm is one of the oldest concurrency control mechanisms used by relational database systems to guarantee data integrity.

In this article, I’m going to explain how the 2PL algorithm works and how you can implement it in any programming language.

Read More

Bulk update optimistic locking 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 we can adjust a bulk update statement so that it takes optimistic locking into consideration.

While Hibernate has been supporting versioned HQL queries for a very long time, it’s actually very easy to achieve this goal even with standard JPQL or JPA Criteria API.

Read More

PostgreSQL trigger consistency check

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 to implement a non-trivial consistency check using a PostgreSQL INSERT and UPDATE trigger.

By using a database trigger after executing an INSERT or UPDATE, we can ensure that the sum of salaries in a given department does not exceed the maximum budget allocated for the given department.

Read More

The best way to fix the Hibernate MultipleBagFetchException

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

Introduction

If you’ve been using Hibernate for some time, there is a good chance you bumped into a MultipleBagFetchException issue:

org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags

In this article, we are going to see the reason Hibernate throws the MultipleBagFetchException as well as the best way to solve this issue.

Read More

Spring Boot performance tuning

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

Introduction

While developing a Spring Boot application is rather easy, tuning the performance of a Spring Boot application is a more challenging task, as, not only it requires you to understand how the Spring framework works behind the scenes, but you have to know what is the best way to use the underlying data access framework, like Hibernate for instance.

In a previous article, I showed you how easily to optimize the performance of the Petclinic demo application. However, by default, the Petclinic Spring Boot application uses the in-memory HSQLDB database, which is not what you’d usually want your application to be optimized for.

In this article, we are going to switch the underlying database from the in-memory HSQLDB to MySQL and run Hypersistence Optimizer to generate a performance tuning report for the JPA and Hibernate data access layer in the context of the MySQL database.

Read More

A beginner’s guide to database deadlock

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 deadlock can occur in a relational database system, and how Oracle, SQL Server, PostgreSQL, or MySQL recover from a deadlock situation.

Read More

The best way to fetch multiple entities by id using 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 we can load multiple entities by id at once when using JPA and Hibernate.

Loading multiple entities by their identifier is a very common requirement when using JPA and Hibernate. Hence, we are going to see how we can optimize the underlying SQL query execution.

Read More

How to map SQL Server JSON columns using 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 easy it is to map an SQL Server JSON column when using the Hibernate Types project.

Not only that the hibernate-types project supports JSON column types for PostgreSQL and MySQL and Oracle, but, as you will see in this article, the JsonStringType works just fine when using Microsoft SQL Server.

Read More

JDBC Driver Maven dependency list

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

Introduction

Ever wanted to connect to a relational database using Java and didn’t know which JDBC Driver Maven dependency to use?

If so, this article is surely going to help you from now on.

Read More

Six years of blogging

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

Quality over quantity

I’ve been blogging for six years already, and every year I like to write a report with the achievements I’ve made over the last year.

If you are curious about my previous reports, check out the following list:

Page Views

Six years of blogging page views

In 2019, I got around 10,547 daily page views, meaning that this year, I’ll get over 3.85 million page views. That’s a 22% traffic increase since 2018.

Overall, in these six years of blogging, I got over 8.8 million page views and 4.5 million visitors. Cool, right?

Six years of blogging overall statistics

Read More