Understand Hibernate @ManyToOne, @OneToMany With Examples

Understand Hibernate @ManyToOne, @OneToMany

Overview @ManyToOne and @OneToMany are standard mappings in Hibernate. Understanding how to use them correctly is the key to mapping entities efficiently in Hibernate. In this post, I will show you how to use these annotations and give examples to demonstrate use cases. The analogy I use is schools and students. In real life, schools … Read more

Using @ColumnTransformer In Hibernate

Using @ColumnTransformer In Hibernate

Overview One of the lesser-known yet powerful annotations in Hibernate is @ColumnTransformer. This annotation let us apply SQL transformations on entity properties when interacting with the database. You can think of this annotation as a two way converter. A real life use case Let’s consider a weather app that initially use Kelvin scale to store … Read more

Why does Hibernate Need A No-arg constructor

Why does Hibernate Need A No-arg constructor

Overview In this post, we are going to explore the reasons why does Hibernate need a no-arg constructor. The no-arg constructor need to be protected or public. A primer on the no-arg constructor When you declare a class without any constructor, the compiler create a default no-arg constructor for you. However, when you define constructor(s) … Read more