final List <Map<String , Object>> roleList;
final Map<Integer, String> roleMap=new HashMap<Integer, String>();
roleList = getSession()
.createQuery("select Id, Name from Emp where dept=:ref")
.setParameter("ref", "accounts")
.list();
for (Map<String, Object> map2 : roleList)
{
roleMap.put((Integer)(map2.get("Id")), (String)map2.get("Name"));
}
MappingBean.setRoleList(roleMap);
The above code is showing class cast exception [Ljava.lang.Object; cannot be cast to java.util.Map.
Is there any way in Hibernate we can get data in the form of List of Maps? My roleList is in the form of map and I want to set the roleList.
Criteria.ALIAS_TO_ENTITY_MAP