Skip to content

Expressions.nullExpresion() in querydsl result in NPE in SqmExpressible #3589

@OHsechun

Description

@OHsechun
kotlin
Spring boot 3.3.2
Spring data jpa 3.3.2 (hibernate 6.5.2)
QueryDSL 5.1.0

java.lang.NullPointerException: Cannot invoke "org.hibernate.type.descriptor.java.JavaType.isInstance(Object)" because the return value of "org.hibernate.query.sqm.SqmExpressible.getExpressibleJavaType()" is null

I used Expressions.nullExpression() with case builder in select clause as below.

val myCase = QMyEntity.myEntity.field1.`when`("count").then(1).otherwise(Expressions.nullExpression())
(field1 field type is String)

return from(QMyEntity.myEntity)
           .select(myCase.count()`as`("alias") ....

In Spring boot 2.7.14 with querydsl 5.0.0 it works well with below query.

select count(case when myentity.field1=? then ? else null end) as col_1_0_, ....
from ...

How can I fix this issue in Spring data jpa 3.3.2 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions