spring数据jpa @query是否支持投影?

时间:2018-03-07 17:31:37

标签: java spring spring-boot spring-data-jpa projection

spring boot version:1.5.10,spring data jpa 1.11.10

在我的MyEntityRespostory中:

 Page<MyEntityPro> findByName(String name,Pageable pageable ) // working

 @("select e from MyEntity e")
 Page<MyEntity> search1(Pageable pageable) // working

 @("select e from MyEntity e")
 Page<MyEntityPro> search2(Pageable pageable) //error-No aliases found in result tuple! Make sure your query defines aliase

我搜索错误并找到: https://jira.spring.io/browse/DATAJPA-885

1 个答案:

答案 0 :(得分:0)

如果使用upper query关键字,则会导致问题。

....
@query("SELECT e FROM MyEntity") // bug
......
@query("select e from MyEntity") // working
...