
Vlad Mihalcea
1000 FOLLOWERS
On Vlad Mihalcea's blog, you can find a lot of articles about Hibernate, Relational Databases, No SQL, Spring, Caching, and other Enterprise-related topics. Vlad is the author of High-Performance Java Persistence https://t.co/QeuIiJjLbQ
Vlad Mihalcea
5d ago
Introduction 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. Articles The pick of this edition is this article that not only explains how B+Tree indexes work in PostgreSQL, but it provides an OSS tool to help you visualize them. Speaking of PostgreSQL, this article explained why it would be useful if PostgreSQL supported Transparent Database Encryption (TDE). If you are using Spring or Spring... Read More
Th ..read more
Vlad Mihalcea
1w ago
Introduction In this article, we are going to see that scaling the data access layer of a Spring application can be done very easily with a YugabyteDB cluster. As I explained in this article, YugabyteDB is an open-source distributed SQL database that offers all the benefits of a typical relational database (e.g., SQL, strong consistency, ACID transactions) with the advantages of a globally-distributed auto-sharded database system (e.g., NoSQL document databases). How to create a local YugabyteDB cluster As I showed in this article, creating a single-node YugabyteDB Docker container is extremel ..read more
Vlad Mihalcea
2w ago
Introduction In this article, I’m going to explain how you can use the BaseJpaRepository from the Hypersistence Utils OSS project as an alternative to the default Spring Data JpaRepository. The reason why I’m not using the default JpaRepository on any of my Spring projects is that it provides some terrible defaults that can be very easily misused, like: The findAll Anti-Pattern The JPA save Anti-Pattern So, there are two ways you can fix the problems induced by the default JpaRepository: You can use the HibernateRepository to deprecate the questionable methods that you... Read More
The post Th ..read more
Vlad Mihalcea
3w ago
Introduction In this article, we are going to see the overhead of acquiring a new connection when using YugabyteDB and why connection pooling is mandatory for performance. Acquiring a database connection using JDBC To interact with a database system, first, we need to acquire a database connection. And, when using Java, we need to obtain a Connection object from the Driver prior to executing any statement. Now, if you inspect the JDBC specification, you will see that there are two ways to obtain a database connection. You can either use the DataSource... Read More
The post YugabyteDB Connectio ..read more
Vlad Mihalcea
1M ago
Introduction In this article, I explain why the Hibernate Types became Hypersistence Utils, and how you can migrate your old dependency to Hypersistence Utils 3.0. Hibernate Types The Hibernate Types project was first created in September 2017 with the goal of offering various Hibernate Types that were not supported natively, like support for JSON or ARRAY column types. Over the years, the project evolved and started offering more utilities beyond the core Hibernate Types. For instance, in 2018, I added support for the CamelCaseToSnakeCaseNamingStrategy. Then, in 2020, I added support for the ..read more
Vlad Mihalcea
1M ago
Introduction In this article, we are going to see how to configure a Spring application to use MDC (Mapped Diagnostic Context) for transaction logging. This technique is going to help us inject the Persistence Context information as well as the associated database transaction identifier in all the log entries emitted from within a @Transactional service method. MDC (Mapped Diagnostic Context) As I explained in this article, MDC is for application logging what the ThreadLocal context is to Java threads. In short, MDC allows us to register key/value sets that are bound to... Read More
The post S ..read more
Vlad Mihalcea
1M ago
Introduction In this article, we are going to see how we can configure Spring Data to register several Hibernate Entity Listeners that can intercept entity state modifications. As I explained in this article, JPA also offers an event listening mechanism that you can configure via the @EntityListeners, @PostPersist or @PostUpdate, or PostRemove annotations. However, the JPA solution is way too limited as it doesn’t allow you to interfere with the EntityManager directly. Therefore, I prefer using the Hibernate Entity Listeners mechanism, which you can easily integrate with Spring Data, as this a ..read more
Vlad Mihalcea
2M ago
Introduction In this article, we are going to see what UUID (Universally Unique Identifier) type works best for a database column that has a Primary Key constraint. While the standard 128-bit random UUID is a very popular choice, you’ll see that this is a terrible fit for a database Primary Key column. Standard UUID and database Primary Key A universally unique identifier (UUID) is a 128-bit pseudo-random sequence that can be generated independently without the need for a single centralized system in charge of ensuring the identifier’s uniqueness. The RFC 4122 specification... Read More
The po ..read more
Vlad Mihalcea
2M ago
Introduction 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. Articles The pick of this edition is this article that celebrates the Spring 6 release, as well as this one about the Spring Boot 3 new version. Related to Spring, I published three new articles on my blog: The best way to do the Spring 6 migration The Spring Data JPA findById Anti-Pattern Spring Data... Read More
The post High-Performance Java Per ..read more
Vlad Mihalcea
2M ago
Introduction In this article, we are going to see how we can write UNION, INTERSECT, and EXCEPT queries with Hibernate. While you could have always used all these relational set operations using native SQL queries, starting with Hibernate 6, you can use UNION, INTERSECT, and EXCEPT in JPQL and Criteria entity queries. This is all possible because of the new Semantic Query Model that Hibernate has introduced in version 6. Domaon Model Let’s assume we have the following Category and Tag entities: We are going to create the following four Category entries:... Read More
The post The best way to us ..read more