Hibernate Cast" arraylist"从List POJO到另一个POJO?

时间:2016-02-17 19:16:44

标签: java hibernate

我尝试使用hibernate和他们的POJO,投射到我的POJO但是 classcastexception 如何修复?

private void open() throws Exception {
    //private ArrayList<Curso> listaCursos = new ArrayList<Curso>();
    try {
        sf = NewHibernateUtil.getSessionFactory();
        se = sf.openSession();
        Query query = se.createQuery("FROM Curso");

        System.out.println(listaCursos);
        List<Curso> lisst = new ArrayList<Curso>();
        for (Object c : query.list()) {
            listaCursos.add((Curso) c);
        }

    } catch (Exception e) {
        System.out.println(e);
    }
}

并查看错误日志:

java.lang.ClassCastException: modelo.DAO.HIBERNATE.POJO.Curso cannot be cast to POJO.Curso

0 个答案:

没有答案