org.hibernate.hql.internal.ast.QuerySyntaxException: table is not mapped

后端 未结 19 1708
滥情空心
滥情空心 2020-12-04 14:59

I have example web application Hibernate 4.3.5 + Derby database 10.10.1.1+ Glassfish4.0 with IDE NetBeans 8.0Beta.

I have the next exception:

Caused          


        
19条回答
  •  失恋的感觉
    2020-12-04 15:29

    Other persons that are using mapping classes for Hibernate, make sure that have addressed correctly to model package in sessionFactory bean declaration in the following part:

    public List list() {
        List list=SessionFactory.getCurrentSession().createQuery("from book").list();
        return list;
    }
    

    The mistake I did in the above snippet is that I have used the table name foo inside createQuery. Instead, I got to use Foo, the actual class name.

    public List list() {                                                                               
        List list=SessionFactory.getCurrentSession().createQuery("from Book").list();
        return list;
    }
    

提交回复
热议问题