简体   繁体   中英

Does spring data jpa @query support projection?

spring boot version: 1.5.10, spring data jpa 1.11.10

In my 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

I search the error and find : https://jira.spring.io/browse/DATAJPA-885

If you use upper query keyword, it will cause the problem.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM