I need multiple columns from multiple tables data.
Using Native Query:
@Query(value = "select t1.name as name, t1.phone as phone, t2.address as address, t2.pincode as pincode
from tablet t1, table2 t2
where t1.id=t2.tab1_id", nativeQuery = true)
List<MultipleColumnValues> getMultipleColumnsFromMultipleTables();
The return type of the above Query is a List of below projection:
public interface MultipleColumnValues {
String getName();
String getPhone();
String getAddress();
String getPincode();
}
I am getting the List successfully.
But:
The results are storing in different variables like,
The column names in the query mentioned are not rendering properly with the projection method Names.
eg: column 'name'(db query) value is stored in getPincode(),
and pincode(db Query) is stored in getAddress()
How to render/map the result set names with the exact projection method names correctly?
This is a bug in Spring Data JPA version that is used in Spring Boot 1.5.2.
You have to upgrade to 1.5.3 then everything will work.
That't link to the issue: https://jira.spring.io/browse/DATACMNS-927