"Got different size of tuples and aliases" exception after Spring Boot 2.0.0.RELEASE migration

In jpa 2.1 putting @Query(nativeQuery = true) annotation on the repository interface method, fixed the issue. Reference:

https://github.com/spring-projects/spring-data-examples/tree/master/jpa/jpa21#support-for-custom-sqlresultsetmapping-with-constructorresult


Change your SqlResultSetMappings to

@SqlResultSetMappings({
    @SqlResultSetMapping(name = TS_TRANS_EMP_STAT,
        columns = {
            @ColumnResult(name = "EMPID", type = Long.class),
            @ColumnResult(name = "CODE", type = String.class),
            @ColumnResult(name = "TOTALCOUNT", type = Integer.class)
        })
}

and change EmpStat from normal class to interface:

public interface EmpStat {
    Long getEMPID();
    String getCODE();
    Integer getTOTALCOUNT();
}

It was a bug, now fixed: jira.spring.io/browse/DATAJPA-1280

Add:

@Query(nativeQuery=true) 

at the top of a new method in the repository.