Skip to content

QueryDSL-JPA + Custom type implementing Number + NumberExpression #3550

@HonoluluHenk

Description

@HonoluluHenk

Observed vs. expected behavior

When using the following Combination

  • a custom Type extending Number, converted using JPA @Converter/AttributeConverter (also happens with all other Hibernate custom types like UserType)
  • a NumberExpression in the JPAQuery like sum()

Example:

var rows = new JPAQuery<>(em)
		.select(myEntity.myCustomNumber.sum())
		.from(myEntity)
		.fetch();

Actual outcome:
I receive java.lang.IllegalArgumentException: Unsupported target type : MyCustomNumber 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

Environment

Querydsl version: 5.0.0-jakarta (does not look like a jakarta-problem, though)

Querydsl module: querydsl-jpa/querydsl-core

Database: any (e.g. hsqldb, postgresql)

JDK: 17 (but the stacktrace indicates this is not a JDK-problem)

Additional details

Works correctly - at least "as expected" :) - in the old Hibernate 5.

(Edit: QueryProjection and Hibernate6 is not necessary. I updated Description + Title accordingly)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions