Hibernate Tips: How to use an ORDER BY clause in a CriteriaQuery
|

Hibernate Tips: How to use an ORDER BY clause in a CriteriaQuery

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: How do I create a CriteriaQuery which returns the selected entities in the ascending order of an attribute?

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…

Entities or DTOs – When should you use which projection?
| |

Entities or DTOs – When should you use which projection?

JPA and Hibernate allow you to use DTOs and entities as projections in your JPQL and Criteria queries. When I talk about Hibernate performance in my online training or at a workshop, I get often asked, if it matters which projection you use. The answer is: YES! Choosing the right projection for your use case…