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.
Three years ago, I started working as a Developer Advocate for the Hibernate team at Red Hat.
Each year, I write a new report to summarize the accomplishments for the Hibernate project and its community. If you’re curious about the previous year reports, check out the
- 2017 report – 2 years as a Hibernate Developer Advocate
- 2016 report – 1 year as a Hibernate Developer Advocate
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.
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.