Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiberate query throws java.util.ArrayList cannot be cast to class java.lang.Enum

Tags:

hibernate

This query on a repository method

@Query(
    "SELECT a FROM AttachmentEntity a " +
        "WHERE (:projectId IS NULL OR a.projectId = :projectId) " +
        "AND (:attachmentTypes IS NULL OR a.attachmentType IN :attachmentTypes) " +
        "AND (:eventType IS NULL OR a.eventType = :eventType) ")
fun getAttachments(
    projectId: Int?,
    attachmentTypes: List<AttachmentType>?,
    eventType: EventType?
): List<AttachmentEntity>

throws this exception, when called:

class java.util.ArrayList cannot be cast to class java.lang.Enum (java.util.ArrayList and java.lang.Enum are in module java.base of loader 'bootstrap')

When I remove :attachmentTypes IS NULL OR, it works.

Could this be a bug in the hibernate query parser?
I could get around this by building the query inside the method, but is there another way to fix this?

like image 563
Marty Avatar asked Oct 20 '25 05:10

Marty


1 Answers

This issue was already reported please see HHH-15968.

like image 103
Marco Belladelli Avatar answered Oct 22 '25 07:10

Marco Belladelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!