The best way to use Spring Data query methods
Introduction In this article, we are going to see how Spring Data query methods are built, when you should use them, and especially when you should avoid them. I decided to write this article after answering this StackOverflow question, which depicts an 87-character-long Spring Data query method. TL;DR, Don’t write query methods that cannot even fit on the screen.
The best way to use UNION, INTERSECT, and EXCEPT with Hibernate
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.
The best way to use the Hibernate TupleTransformer
Introduction In this article, I’m going to explain how the Hibernate TupleTransformer works and how to use it to replace the deprecated ResultTransformer.
The best way to write a Spring Data Exists Query
Introduction In this article, I’m going to show you the best way to write a Spring Data Exists Query that’s efficient from an SQL perspective. While doing consulting, I’ve encountered several options that are commonly used without developers knowing there are actually better alternatives.
JPA and Hibernate Query setParameter – User Guide
Introduction In this article, I’m going to show you how the JPA Query setParameter method works for basic entity attributes, and how you can use it when dealing with custom Hibernate types. If you ever stumbled on the “column is of type jsonb but expression is of type bytea” PostgreSQL issue and didn’t know how to fix it, then you should definitely read this article.
How to get the SQL query from JPQL or JPA Criteria
Introduction In this article, I’m going to show you how you can get the auto-generated SQL query from a JPQL or JPA Criteria API entity query.
Hypersistence Optimizer Runtime Scanner
Introduction The 2.0 version of the Hypersistence Optimizer has just arrived, and it comes with a runtime scanner that is capable of analyzing your JPA and Hibernate data access operations and queries and give you tips about how you can speed up your application. Along with the JPA and Hibernate mapping and configuration scanners, the runtime scanner makes Hypersistence Optimizer an indispensable tool for building High-Performance Java Persistence applications.
How to return a Map result from a JPA or Hibernate query
Introduction In this article, I’m going to show you how you can return a Java Map result when executing a JPA query. I decided to write this article after answering a similar question on StackOverflow.
The best way to use a Hibernate ResultTransformer
Introduction In this article, I’m going to present the best way to use a Hibernate ResultTransformer so that you can customize the result set of a given JPA or Hibernate query. As I already explained, the Hibernate ResultTransformer is a very powerful mechanism, allowing you to customize a JPQL, Criteria API, or native SQL query result set in any possible way.
How to get the query execution plan on SQL Server
Introduction In this article, we are going to see how we can get the query execution plan when using the SQL Server relational database system. The execution plan allows you to understand the operations done by the database engine when executing a specific SQL query.