I'm getting an exception when I try to save some data through hibernate persistence layer, the exception is
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): hbm.Employee
public void saveEmployee(Employee empValue) {
Session session = null;
Transaction tx = null;
session = HibernateSessionFactory.getSession();
tx = session.beginTransaction();
Employee emp;
if (empValue.getEmpcode() != null) {
emp = (Employee) session.get(Employee.class, empValue.getEmpcode());
if (emp != null) {
System.out.println("Test");
emp.setEmpcode(empValue.getEmpcode());
emp.setDepartment(createDepartment("DEEE"));
emp.setEmpfname(empValue.getEmpfname());
emp.setEmplname(empValue.getEmplname());
emp.setEmpdob(empValue.getEmpdob());
emp.setEmpstatus(empValue.getEmpstatus());
emp.setEmptelno(empValue.getEmptelno());
emp.setAuditfield(empValue.getAuditfield());
session.update(emp);
}
} else
{
emp = new Employee();
emp.setEmpcode(empValue.getEmpcode());
emp.setDepartment(createDepartment("DEEE"));
emp.setEmpfname(empValue.getEmpfname());
emp.setEmplname(empValue.getEmplname());
emp.setEmpdob(empValue.getEmpdob());
emp.setEmpstatus(empValue.getEmpstatus());
emp.setEmptelno(empValue.getEmptelno());
emp.setAuditfield(empValue.getAuditfield());
session.save(emp);
}
tx.commit();
}
as you can see the class get assigned within appropriate places, I'm confused about the exception, expecting some help..