I am using jbcTemplate and I am encountered ORA-01008 exception.
package com.awzpact.prayas.service;
import com.awzpact.uam.dao.BaseJdbcTemplate;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Service;
/**
*
* @author zia.khan
*/
@Service
public class PayCodeDetailListService extends BaseJdbcTemplate {
public List<Map<String, Object>> searchPayCodeByempCode(String tabSuffix, String empCode, String yyyyMm) {
MapSqlParameterSource param = new MapSqlParameterSource();
String tableName = "Salary_detail_report_082018";
String query = "SELECT "
+ " DISTINCT PAY_CODE, "
+ " PAY_CODE_DESC, "
+ " AMOUNT, "
+ " row_number() over (Order by EMP_CODE ) AS ROW_NUM "
+ " FROM " + tableName
+ " WHERE EMP_CODE=:EMP_CODE "
+ " AND YYYYMM=:YYYYMM "
+ " AND PAY_CODE NOT IN (997,998,999) "
+ " ORDER BY PAY_CODE ASC ";
param.addValue("empCode", empCode);
param.addValue("YYYYMM", yyyyMm);
List<Map<String, Object>> employees = queryForList(query);
if (employees != null && !employees.isEmpty()) {
for (Map<String, Object> employee : employees) {
for (Iterator<Map.Entry<String, Object>> it = employee.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, Object> entry = it.next();
String key = entry.getKey();
Object value = entry.getValue();
System.out.println(key + " = " + value);
}
}
}
return employees;
}
}
This line List<Map<String, Object>> employees = queryForList(query);
throws and exception.
In addition I also want to know, the result returned after execution of query can be directly bind into the POJO.
Simple meaning, My query will returning limited number of columns, like 10,13,15 50,90 etc.
Now I don't want to implement mapper, because there are 95 records and for limited records i need to write big mapper and each time i also need to check the null values while mapping the row.
I want to to directly bind the result in the domain.
so after R&D i came up with this solution and while testing i am encountering this, kindly suggest me the best solution.