querydsl
querydsl copied to clipboard
JPA + custom type + Number + NumberExpression throws IllegalArgument Unsupported target type
Observed vs. expected behavior
(This is a continuation from the original QueryDSL issue #3550)
When using the following Combination
- a custom type extending Number (imho this seems to trigger the strange behavior)
- a custom
@Converter
/AttributeConverter
(also happens with all other Hibernate custom types like UserType) - a NumberExpression in the JPAQuery:
sumAggregate()
(formerly: sum())
Example:
var result = new JPAQuery<>(em)
.select(myEntity.myCustomNumber.sumAggregate())
.from(myEntity)
.fetchOne();
Actual outcome:
java.lang.IllegalArgumentException: Unsupported target type : MyCustomNumber
is thrown instead of a valid result.
Expected outcome:
The query-result.
Steps to reproduce
I created a reproducer with unit tests showing what works and what doesn't: https://github.com/dvbern/bug-reproducers-querydsl-jpa-hibernate6/tree/openfeign
Environment
Querydsl version: 6.0.0.RC1
Querydsl module: querydsl-jpa
Database: any (e.g. hsqldb, postgresql)
JDK: 17 (but the stacktrace indicates this is not a JDK-problem)