Tim*_*per 19
您可以在查询中使用基于TemplateExpression的任意JPQL语法注入.
例如
query.where(Expressions.booleanTemplate("func1({0}, {1})", arg1, arg2));
Run Code Online (Sandbox Code Playgroud)
如果你使用Hibernate 4.3或任何其他JPA 2.1兼容的提供者,你可以使用函数语法调用SQL函数https://bugs.eclipse.org/bugs/show_bug.cgi?id=350843
所以这个例子会变成
query.where(Expressions.booleanTemplate("function('func1', {0}, {1})", arg1, arg2)"));
Run Code Online (Sandbox Code Playgroud)