Skip to content

Missing constructor exception when selecting record fields #4124

@ucmjswink

Description

@ucmjswink

In 3.5.1 and later versions, the following repository method fails:

@Query("select de.field from DemoEntity de where de.id=:id")
Set<DemoField> getDemoFields(@Param("id") Long id);

DemoField is a record type. The method fails with:

org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.query.SemanticException: Missing constructor for type 'DemoField' [select new com.example.demo.DemoField(de.field) from DemoEntity de where de.id = :id]

This works in 3.5.0 and earlier.

Demo project: https://github.com/ucmjswink/SpringDataJpaRecordMissingConstructor

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