I've changed EmployeeDao class for simpler version:
Code:
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
import java.util.List;
public class EmployeeDao {
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate){
this.hibernateTemplate = hibernateTemplate;
}
public HibernateTemplate getHibernateTemplate(){
return hibernateTemplate;
}
public Employee getEmployee(Integer id){
return (Employee) this.hibernateTemplate.load(Employee.class, id);
//List<Employee> results = hibernateTemplate.find("from Employee where id = " + id);
//return results.size() > 0 ? results.get(0) : null;
}
public void saveOrUpdate(final Employee employee){
hibernateTemplate.saveOrUpdate(employee);
}
}
But there is the same problem. I've tried to use find function :
Code:
List<Employee> results = hibernateTemplate.find("from Employee where id = " + id);
return results.size() > 0 ? results.get(0) : null;
and in this version everything is OK ! I don't know where is the problem. Maybe with Employee.class ?
Can somebody help me ? PLZ