In this article, we are going to see how the Hibernate event listeners work and how you add your custom listeners to intercept entity changes and replicate them to other database tables.
Recently, one of my blog readers asked a very good question on StackOverflow.
Since my main goal as a Hibernate Developer Advocate is to help Java developers get the most out of JPA and Hibernate, I decided that this is a good opportunity to talk about the Hibernate event listener mechanism.
Continue reading “How to intercept entity changes with Hibernate event listeners”
In this article, we are going to see the best way to initialize LAZY proxies and collections when using JPA and Hibernate.
I decided to write this article because there are way too many resources available on the Internet that mislead the reader into using awkward and inefficient practices.
Continue reading “The best way to initialize LAZY entity and collection proxies with JPA and Hibernate”
In this article, we are going to see how you can execute SQL functions with multiple parameters in JPQL queries with Hibernate. I recently stumbled on this requirement while answering this StackOverflow question which is a never-ending source of inspiration for articles on my blog.
Continue reading “How to execute SQL functions with multiple parameters in a JPQL query with Hibernate”
In this article, we are going to how the JPQL DISTINCT keyword behaves depending on the underlying entity query type.
Continue reading “The best way to use the JPQL DISTINCT keyword with JPA and Hibernate”
In this article, you are going to learn how to map cameCase entity properties (e.g.
phoneNumber) to snake_case column names (e.g.
phone_number) using a Hibernate naming strategy.
While you could achieve the same goal with the
name attribute of JPA
@Column annotation, it’s much more convenient to use a custom Hibernate strategy to apply this naming convention consistently.
Continue reading “How to map camelCase properties to snake_case column names with Hibernate”