Hibernate Tips: How to Handle NULL Values while Ordering Query Results in JPQL
|

Hibernate Tips: How to Handle NULL Values while Ordering Query Results in JPQL

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: I need to order the result of a JPQL query based on a column that contains NULL values. How…

5 Common Hibernate Mistakes That Cause Dozens of Unexpected Queries
|

5 Common Hibernate Mistakes That Cause Dozens of Unexpected Queries

If there is one thing that’s often criticized about JPA and Hibernate, it’s that it sometimes execute more queries than you expected. And I’m not talking about 1 or 2 additional queries. I’m talking about dozens or even hundreds of them. The worst thing about it is that you don’t recognize that problem if you…

Hibernate Tips: What’s the Difference between JOIN, LEFT JOIN and JOIN FETCH
|

Hibernate Tips: What’s the Difference between JOIN, LEFT JOIN and JOIN FETCH

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: I saw JPQL queries using JOIN, LEFT JOIN and JOIN FETCH statement. What are the differences between these 3…

JPA 2.2’s new getResultStream() method and how you should NOT use it
|

JPA 2.2’s new getResultStream() method and how you should NOT use it

JPA 2.2 introduced several new features, and one of them is the new getResultStream() method. This method is now part of the Query interface. As you might guess from its name, it allows you to retrieve the result of your query as a Stream. The goal of this method is to provide an efficient way to…

Hibernate Tips: How to select a specific subclass from an inheritance hierarchy
|

Hibernate Tips: How to select a specific subclass from an inheritance hierarchy

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: I have a many-to-many association to the superclass of an inheritance hierarchy. How can I select only a certain…