Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception with BigDecimal constant in JPAQuery creation #228

Closed
steeltomato opened this issue Sep 13, 2012 · 1 comment
Closed

Exception with BigDecimal constant in JPAQuery creation #228

steeltomato opened this issue Sep 13, 2012 · 1 comment

Comments

@steeltomato
Copy link

@steeltomato steeltomato commented Sep 13, 2012

Encountered a problem when trying to do a comparison on a NumberPath after doing math on it in a JPAQuery. For example:

...where(bigd1.divide(bigd2).loe( new BigDecimal("1.00") ))

with bigd1 and bigd2 both being NumberPath 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) it executes just fine.

Assuming this was a type coercion problem, I tried to cast the BigDecimal paths to Double.class (castToNum) but this causes additional exceptions:

java.lang.IllegalArgumentException: Got no pattern for CAST
at com.mysema.query.support.SerializerBase.visitOperation(SerializerBase.java:318) [querydsl-core-2.7.0.jar:]
at com.mysema.query.jpa.JPQLSerializer.visitOperation(JPQLSerializer.java:368) [querydsl-jpa-2.7.0.jar:]
at com.mysema.query.jpa.JPQLSerializer.visitNumCast(JPQLSerializer.java:377) [querydsl-jpa-2.7.0.jar:]

Environment:
QueryDSL 2.7.0
Mvn entity generation using plugin
JPA2 wrapping Hibernate 4.0.1 against a SQL Server 2012 datasource

timowest added a commit that referenced this issue Sep 15, 2012
@timowest
Copy link
Member

@timowest timowest commented Sep 29, 2012

Released in 2.8.0

@timowest timowest closed this Sep 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants