How to call mysql function using querydsl?

前端 未结 1 1290
时光说笑
时光说笑 2021-01-01 21:40

I am in little hurry so, i just want to ask a quick question about querydsl. According to my research, query dsl doesn\'t support stored procedure but can support database f

1条回答
  •  孤街浪徒
    2021-01-01 22:25

    You can use TemplateExpression based injections of arbitrary JPQL syntax into your query.

    e.g.

    query.where(Expressions.booleanTemplate("func1({0}, {1})", arg1, arg2));
    

    If you use Hibernate 4.3 or any other JPA 2.1 compliant provider you can use the FUNCTION syntax to invoke SQL functions https://bugs.eclipse.org/bugs/show_bug.cgi?id=350843

    So the example would turn into

    query.where(Expressions.booleanTemplate("function('func1', {0}, {1})", arg1, arg2)"));
    

    0 讨论(0)
提交回复
热议问题