with bigd1 and bigd2 both being NumberPath<BigDecimal> paths, results in this trace:
java.lang.IllegalArgumentException: Parameter value [1.0] did not match expected type [java.math.BigDecimal]
at org.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:370) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:343) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:370) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:437) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:67) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at com.mysema.query.jpa.impl.JPAUtil.setConstants(JPAUtil.java:44) [querydsl-jpa-2.7.0.jar:]
at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:136) [querydsl-jpa-2.7.0.jar:]
at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:104) [querydsl-jpa-2.7.0.jar:]
at com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:272) [querydsl-jpa-2.7.0.jar:]
However, without the divide (which happens to return a NumberExpression<Double>?) it executes just fine.
I am lucky in that I happen to have this BigDecimal in the DB so I can do 3 or 4 joins and grab it, but it adds a fair bit of overhead that seems unnecessary. This is a contrived example, in the real use case I am calculating a percentage and comparing to a fixed threshold (ABS(bigd1 - bigd2) / bigd1) * 100) > threshold).
Env:
QueryDSL 2.7.0
JPA2
Maven entity generation
Thanks for your help!