Specifying Database Function in JPA / Hibernate NamedQuery

How to specify database function in JPA / Hibernate NamedQuery?

Oddly enough, hibernate JQL does not recognize the RIGHT function. Without using a substring, is there a way in hibernate to specify any valid database function in NamedQuery? I would prefer not to create my own query or CriteriaQuery.

+3
source share
1 answer

Prior to JPA 2.1, JPQL does not support the direct use of database functions (other than those invoked as a result of using the used JPQL function).

In accordance with the specification functions, JPA 2.1 is invoked as follows:

function_invocation :: = FUNCTION (function_name {, function_arg} *)

function_arg :: =
literal | state_valued_path_expression |
input_parameter |
scalar_expression

In the case of the RIGHT function, it looks like this:

FUNCTION("RIGHT, "some_string_possibly_path", 3) 

With Hibernate, one of the possibilities is to expand the dialect as described in this .

+3
source

All Articles