
Transactions and Concurrency Control
Posted on August 28, 2020 by vladmihalcea
Are you struggling with performance issues in your Spring, Jakarta EE, or Java EE application?
What if there were a tool that could automatically detect what caused performance issues in your JPA and Hibernate data access layer?
Wouldn’t it be awesome to have such a tool to watch your application and prevent performance issues during development, long before they affect production systems?
Well, Hypersistence Optimizer is that tool! And it works with Spring Boot, Spring Framework, Jakarta EE, Java EE, Quarkus, Micronaut, or Play Framework.
So, rather than fixing performance issues in your production system on a Saturday night, you are better off using Hypersistence Optimizer to help you prevent those issues so that you can spend your time on the things that you love!
Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.
The pick of this edition is this article that explains how you can activate the slow query log in PostgreSQL using either the log_duration setting or the pg_stat_statements extension.
If you want to implement an audit log mechanism using PostgreSQL, then you can use a functional trigger to intercept INSERT, UPDATE, and DELETE statements and store the state of the row before and after the DML statement is executed in jsonb columns. For more details about this technique, check out this article.
PostgreSQL provides a great variety of column types, and for store date and time info, you can use date, time, timestamp, tsrange, or daterange. If you want to get a better understanding of all these types, then you should definitely read this article.
Sometimes, the default PostgreSQL statistics might not be suitable for all types of queries, so you need to enable the extended statistics to provide more accurate data value distribution info to the database optimizer. For instance, this article explains how you can optimize a certain query so that its execution is reduced from 2 minutes to 42 milliseconds.
SQL provides many operators, that, unfortunately, are either not known very well or not employed. For example, the ANY operator allows you to match a given value against a list of values resulting from a subquery execution or from a VALUES clause. If you are interested in getting a better understanding of how the ANY operator works, then check out this article.
The 5.4.21 version of Hibernate ORM has been released. For more details about this release, check out the release notes on Jira.
There are many social media platforms, but for me, Twitter is the one I like best. Here are the best tweets I posted since the last newsletter:
I use Tab-Driven Development. The more difficult the task, the more browser tabs I open.
— Vlad Mihalcea (@vlad_mihalcea) August 19, 2020
Developing software is easy. Developing software with other people is hard.
— Vlad Mihalcea (@vlad_mihalcea) August 17, 2020
Developers are very indulgent when it comes to their own code, but extremely critical when it comes to other people's code
— Vlad Mihalcea (@vlad_mihalcea) August 22, 2020
When you add a library to your project, all the library problems are now your problems as well.
— Vlad Mihalcea (@vlad_mihalcea) August 15, 2020
If you ignore the non-functional requirements, you end up with a non-functional product.
— Vlad Mihalcea (@vlad_mihalcea) August 20, 2020
Get in touch with my latest articles!
The following StackOverflow answers have been trending over the past two weeks:
@MappedSuperclass vs. @Inheritance@ElementCollection@ManyToOne JPA associationCategory: Newsletter Tags: hibernate, java, jpa, PostgreSQL, SQL
Vlad Mihalcea

Transactions and Concurrency Control