How to call mysql function using querydsl?

自作多情 提交于 2019-12-18 14:49:32

问题


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 functions. My Question is how can we invoke those database functions using querydsl?


回答1:


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)"));


来源:https://stackoverflow.com/questions/22984343/how-to-call-mysql-function-using-querydsl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!