Is this possible: JPA/Hibernate query with list property in result?

前端 未结 3 594
无人及你
无人及你 2020-12-14 10:51

In hibernate I want to run this JPQL / HQL query:

select new org.test.userDTO( u.id, u.name, u.securityRoles)
FROM User u
WHERE u.name = :na         


        
3条回答
  •  再見小時候
    2020-12-14 11:13

    I believe you need to declare a 0-arg constructor in your UserDTO class.

    EDIT: Or a constructor which takes Integer instead of int as the first argument. When looking up constructors using reflection Hibernate might not treat them as 'compatible' types.

    Basically, I would focus on the Unable to locate appropriate constructor on class [...UserDTO] part of the message.

提交回复
热议问题