I\'m using Spring JPA and I need to have a native query. With that query, I need to get only two fields from the table, so I\'m trying to use Projections. It isn\'t working
You can return list of Object Array (List) as return type of the native query method in repository class.
@Query(
value = "SELECT [type],sum([cost]),[currency] FROM [CostDetails] " +
"where product_id = ? group by [type],[currency] ",
nativeQuery = true
)
public List
for(Object[] obj : objectList){
String type = (String) obj[0];
Double cost = (Double) obj[1];
String currency = (String) obj[2];
}