JPA Data Repositories with SqlResultSetMapping and native queries

前端 未结 3 2020
梦如初夏
梦如初夏 2020-12-16 14:19

I was stuck with the following situation:

My entities are related to each other, but in such a way that i could not use JPQL. I was forced to use native SQL. Now I w

3条回答
  •  孤街浪徒
    2020-12-16 15:00

    You need to mark your query as a query :) And you need to use MyVO instead of MyEntity, because that is the entity you have your resulsts mapped to

    @Repository
    public interface MyRepository extends JpaRepository {
    
        @Query(nativeQuery = true)
        List findAllOfMyVO(@Param("param1") String param1, @Param("param2") String param2);
    }
    

提交回复
热议问题