My service code here
public HashMap<String, Object> syncEmployees(Long updatedAt, String userId) {
HashMap<String, Object> outputMap = new LinkedHashMap<String, Object>();
**List<String>** outputEmployee = employeeDao.getEmployeeSyncDetails(updatedAt);
System.out.println("\n\n Size : "+outputEmployee.size()+"\nOutput : "+outputEmployee);
outputMap.put("employee", outputEmployee);
return outputMap;
}
Dao code which is return type is list of string List(String)
**List<String>** getEmployeeSyncDetails(@Param("updatedAt") long updatedAt);
.XML mapper and query where method returns list of xyzModel
<resultMap id="xyzmap" type="xyzModel" >
<result property="userId" column="user_id" />
<result property="employeeCode" column="employee_code" />
<result property="designationId" column="designation_id" />
</resultMap>
<select id="getxyzDetails" resultMap="xyzmap">
SELECT
user_id, ua.employee_code, designation_id
FROM users
WHERE updated_at > #{updatedAt}
ORDER BY updated_at ASC
</select>
And output is like Size : 3 Output : [com.webapp.models.xyzModel@1567524c, com.webapp.models.xyzModel@7744c2cd, com.webapp.models.xyzModel@43515de7]
My question is how its is working? How xyzmodel is getting populated in list of String actually my problem is XML mapper return xyzModel but if I write any other model like UserModel or String or any other model it is not showing any error or execute perfectly with proper output. If we process this list then only he send error java.lang.ClassCastException