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

How To use @Formula in Hibernate

How To use @Formula in Hibernate

Overview From the official documentation, a Formula mapping defines a “derived” attribute (that means, not persisted), whose state is determined from other columns and functions when an entity is read from the database. You’d probably know other annotation that make a field not persisted to the database: @Transient. While they both allow you to create … 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