I have a complex SQL query which may have different number of parameters in where section. So, query sql should be constructed manually. As a result, I get array of objects which contains 45 fields, each of them I will have to case, convert, etc. I can't use result set mapping because it requires a stable SQL which I should specify in annotation. So the question is is there a way to return pojo or at least map with columns names rather than access all objects by index?
String sql = "select col1 as column1, ...., columnN as columnN from table where col1=2 ";
if(param1!=null){
sql+=" AND param1="+param1;
}
....
Query q = manager.createNativeQuery(sql);
//getting list on object arrays of 45 fields, would like to have POJO or at least map
List list = q.getResultList();