utilisatio d'une function dans une requête HQL
Bonjour,
j'utilise une application SPRING/JPA/HIBERNATE/POSTGRES
Le but est d'utiiser dans une function custom dans une query HQL
J'utilise dans ma data base la function suivante
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
CREATE OR REPLACE FUNCTION movements.isnumeric(text) RETURNS BOOLEAN AS $$
DECLARE x NUMERIC;
BEGIN
x = $1::NUMERIC;
RETURN TRUE;
EXCEPTION WHEN others THEN
RETURN FALSE;
END;
$$
STRICT
LANGUAGE plpgsql IMMUTABLE; |
je définit mon diaLect custom pour définir ma function
Code:
1 2 3 4 5 6 7 8 9 10 11
|
import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hibernate.dialect.function.StandardSQLFunction;
public class CustomPostgreSQL94Dialect extends PostgreSQL94Dialect {
public CustomPostgreSQL94Dialect() {
super();
registerFunction("isnumeric", new StandardSQLFunction("isnumeric"));
}
} |
avec dans mon fichier appication.properties a Ligne suivante
Code:
1 2
|
spring.jpa.properties.hibernate.dialect=package.CustomPostgreSQL94Dialect |
Voici ma requête HQL
Code:
1 2
|
@Query("select hr, emp from HREntity hr left outer join EmployeeEntity emp on FUNCTION('isnumeric',hr.employeeId) and emp.account = FUNCTION('TO_NUMBER',hr.employeeId) order by hr.effectiveDate") |
Pourtant, j'ai l'erreur suivante au démarrage
Code:
1 2
|
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: FUNCTION (isnumeric) near line 1, column 153 [select hr, emp from package1.HREntity hr left outer join package2.EmployeeEntity emp on FUNCTION('isnumeric',hr.employeeId) and emp.account = FUNCTION('TO_NUMBER',hr.employeeId) order by hr.effectiveDate] |
Pouvez-vous m'aider ?