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?
-
Wouldn't this article answer your question ?Laurent S.– Laurent S.2014-04-10 09:46:50 +00:00Commented Apr 10, 2014 at 9:46
-
yeah, i have gone through it lots of time. But it is little out dated based on the current version of querydsl.Mani Rai– Mani Rai2014-04-10 09:51:44 +00:00Commented Apr 10, 2014 at 9:51
-
My bad. Consider I haven't said anything then :-)Laurent S.– Laurent S.2014-04-10 09:56:34 +00:00Commented Apr 10, 2014 at 9:56
Add a comment
|
2 Answers
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)"));
7 Comments
Mani Rai
Wow.. what a coincidence timo.. i just saw and read slide.. you got it almost all in it i need to know.. thank you.. and i ll definitely try your suggestion..
renanleandrof
@Timo I'm trying this but i receive an: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node
spr
Nice one. And also is it possible to handle more functions (nested inner functions) in a single call?
specializt
so ... basically ... QueryDSL doesnt support typesafe functions although it would be possible to extract the types via @NamedStoredProcedureQuery. Thats sad.
Elva
Hi, @renanleandrof, have you solve the problem? I got the same error:
unexpected AST node. My code: Expressions.booleanTemplate("FIND_IN_SET({0}, {1})", arg1, arg2) |