Welcome to the Hibernate community newsletter in which we share blog posts, forum, and StackOverflow questions that are especially relevant to our users.
I released a training video about the best way to log SQL statements with JDBC and Hibernate.
If you liked it, then don' forget to subscribe to my YouTube channel. I’ll release a new video every week, so stay tuned for more.
The pick of this Newsletter is this article by Randall Hyde from 2009 about the Fallacy of Premature Optimization. Way too often, performance is not considered from the very beginning when designing an enterprise application, and neglecting performance can have a serious impact when the application is launched into production.
Reading database Execution Plans is not a trivial thing to do. This article takes a different approach and tries to explain various algorithms employed by an Execution Plan using Java and C++ code examples.
While fetching entities is suitable when you plan to modify them, DTO projections are more convenient when for read-only transactions. Check out this article about the best way you can map a DTO projection using JPA and Hibernate.
If you’re using Spring Data JPA and want to use an automatic schema migration tool like Liquibase, then you should definitely read this step-by-step tutorial.
Whenever you find yourself self-joining two tables to correlate aggregate functions with the original table rows, you are better off using a Window Function. This article gives you two solutions to a given SQL problem: one with Window Functions and one without them. Not only that the Window Function query is more expressive, but it’s more efficient as well.
If you want to learn the difference between save, persist, merge, and saveOrUpdate, this article offers a very good introduction on this topic. While at it, there’s also a performance impact related to merge when doing batch processing. Luckily, the Hibernate-specific update method is there to help you tackle this issue.
Hibernate is extremely flexible.
For instance, you can even use
a Composite Identifier where one of the columns uses a
This is probably one of the few use cases where the JPA
@IdClass construct actually makes sense.