Feb 20, 2017 10:04:26 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/sinisukasystem] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: java.lang.Integer cannot be cast to com.hendri.domain.ProductType] with root cause java.lang.ClassCastException: java.lang.Integer cannot be cast to com.hendri.domain.ProductType at com.hendri.dao.EmployeeDAOImpl.getAllEmployees(EmployeeDAOImpl.java:83) at com.hendri.service.EmployeeServiceImpl.getAllEmployees(EmployeeServiceImpl.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
@SuppressWarnings("unchecked")
@Override
public List<Employee> getAllEmployees(String employeeName) {
String query = "SELECT e.* FROM Employees e WHERE e.name like '%"+ employeeName +"%'";
List<Object[]> employeeObjects = hibernateUtil.fetchAll(query);
List<Employee> employees = new ArrayList<Employee>();
//List<ProductType> producttype = new ArrayList<ProductType>();
for(Object[] employeeObject: employeeObjects) {
Employee employee = new Employee();
long id = ((BigInteger) employeeObject[0]).longValue();
int age = (int) employeeObject[1];
String name = (String) employeeObject[2];
float salary = (float) employeeObject[3];
ProductType productType = (ProductType) employeeObject[4];
employee.setId(id);
employee.setName(name);
employee.setAge(age);
employee.setSalary(salary);
employee.setProductType(productType);
employees.add(employee);
}
System.out.println(employees);enter code here
return employees;
}