I want to call a function in my query. For example:
SELECT myT.col1, myT.col2, myT.col3, fun_get_calculatedCol(myT.col4) as calcCol FROM myTable myT
In my myTableRepository i can do the following:
@Query("SELECT myT.col1, myT.col2, myT.col3 from MyTable myT")
List<MyTable> getCustomColumns();
but adding a function call to the statement does not work:
@Query("SELECT myT.col1, myT.col2, myT.col3, fun_get_calculatedCol(myT.col4) as calcCol from MyTable myT")
List<MyTable> getCustomColumns();
Is there a way to get it work in JPQL?
My error:
Caused by: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'fun_get_calculatedCol' {originalText=fun_get_calculatedCol}