Using the Optimal Query Approach and Projection for JPA and Hibernate

Using the Optimal Query Approach and Projection for JPA and Hibernate

Using JPA and Hibernate, you can choose between various ways to query your data, and each of them supports one or more kinds of projections. That provides you with lots of options to implement your persistence layer. But which one fits your use case? And which one should you avoid if you want to optimize…

Hibernate Tip: Difference between @JoinColumn and @PrimaryKeyJoinColumn

Hibernate Tip: Difference between @JoinColumn and @PrimaryKeyJoinColumn

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 post a comment below. Question: Himanshu Srivastava asked today’s question on my YouTube channel: “What’s the difference between@JoinColumn and @PrimaryKeyJoinColumn? Also, should we use…

The Builder Pattern – How to use it with Hibernate

The Builder Pattern – How to use it with Hibernate

When I shared last week’s article about implementing the fluent interface pattern on twitter, I got asked about using the builder pattern for your entities. Implementing the builder pattern for your entities can massively improve the readability of your business code. In contrast to the fluent interface pattern, there is nothing in the JPA specification…

Hibernate Tip: Create an EntityGraph with multiple SubGraphs

Hibernate Tip: Create an EntityGraph with multiple SubGraphs

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 post a comment below. Question: On my tutorial about JPA’s EntityGraphs, Bipin Shrestha asked the following question: “Can you show me an example of…