1

I have a package with similarity functions installed on my Postgres DB. I was calling them using pure SQL on a JDBC, and it was working as expected.

Now I'm trying to refactor my code to use QueryDSL. The first step of the similarity function is set a limit, between 0 and 1, so that only results above that given threshold are returned. I'm trying this way:

NumberExpression<Float> sim = Expressions.numberTemplate(Float.class, "set_limit({0})", "0.2"); query.singleResult(sim);

I get the following error: java.lang.IllegalArgumentException: No joins given

I know I haven't passed an EntityPath. If I try and use any EntityPath, I get the error:

`[[IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
 \-[METHOD_CALL] MethodNode: '('
    +-[METHOD_NAME] IdentNode: 'set_limit' {originalText=set_limit}
    \-[EXPR_LIST] SqlNode: 'exprList'
       \-[NAMED_PARAM] ParameterNode: '?' {name=1, expectedType=null}
]]`

After that, I'd call another DB function, but I guess the solution would be the same.

Is this possible with QueryDSL?

1 Answer 1

1

set_limit isn't valid JPQL, that's why Hibernate throws an exception. Querydsl JPA maps internally to JPQL, and Querydsl SQL to SQL.

If you need SQL expressivity, like in this case, you will need to use Querydsl SQL instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.