I was testing Spring Data 1.10.4.RELEASE, following the example in Spring Data Docs http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections
an
I had the same issue and when I changed projections from interfaces to pojo classes it generated SQL properly.
If you want use the annotation @Query with Spring Data Projections you have to use field alias and you need to make sure you alias the projects matching the projection fields. The following code should work for question 1:
interface PersonRepository extends CrudRepository<Person, Long> {
@Query("select p.firstName as firstname, p.address as address from Person p where p.firstName = ?1")
PersonLimited findPersonByFirstNameProjectedForLimitedData(String firstName);
}
Another alternative that you can use is define your queries with Property Expressions. whenever is possible:
interface PersonRepository extends CrudRepository<Person, Long> {
List<PersonLimited> findByFirstName(String firstName);
}