Spring JPA native query with Projection gives “ConverterNotFoundException”

后端 未结 5 895
遇见更好的自我
遇见更好的自我 2020-12-10 11:22

I\'m using Spring JPA and I need to have a native query. With that query, I need to get only two fields from the table, so I\'m trying to use Projections. It isn\'t working

5条回答
  •  没有蜡笔的小新
    2020-12-10 12:07

    The query should be using a constructor expression:

    @Query("select new com.example.IdsOnly(t.id, t.otherId) from TestTable t where t.creationDate > ?1 and t.type in (?2)")
    

    And i dont know Lombok, but make sure there is a constructor that takes the two IDs as parameters.

提交回复
热议问题