Hibernate: use HQL inside @Formula annotation?

From what I tested, it seems that you can use standard SQL inside the @Formula annotation. The documentation is not very descriptive regarding this function (I found a maximum of one paragraph about this), so I was wondering if I could use HQL in any way or if there was another function that would allow me to load an object property using an HQL query.

+4
source share
1 answer

You're right. @Formula allows you to use the actual column name.

An important feature of HQL is the use of the java property name to refer to the actual column name. If you want to refer to property names when retrieving a formula value, you can simply implement the formula logic in the receiver of your displayed POJOs.

+5
source

Source: https://habr.com/ru/post/1412404/


All Articles