I'm trying to add the records fetched from select query to a map.
Below is list implementation. it adds the employee object to the list :
public List<Employee> getEmployee() throws Exception {
String sql = "select * from Employee";
List< Employee > emp = new ArrayList< Employee>();
try {
emp = (List< Employee >) jdbcTemplate.query(sql, new Object[]{}, new EmployeeMapper());
} catch (Exception e)
{
throw new Exception("Exception occured while getting the emp ID :",e);
}
return emp;
}
I need the map implementation which will store the primary key as the key and the remaining columns(object) as the value in the map.
for ex:
employee:
[Key]->empId [Value]->[empNm empCode empAddr empSal]
1 John 123 123 main st 4000
2 Doe 456 546 main st 6000
Map<String[empid], Object[employee]>
ASKER