org.hibernate.hql.ast.QuerySyntaxException:3QException in thread "main" org.hibernate.hql.ast.QuerySyntaxException:news is not mapped [from news] 一直是这个错误,困扰了我好多天,不知道哪里错了,增删改都可以就是 public List g

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/20 14:54:52
org.hibernate.hql.ast.QuerySyntaxException:3QException in thread

org.hibernate.hql.ast.QuerySyntaxException:3QException in thread "main" org.hibernate.hql.ast.QuerySyntaxException:news is not mapped [from news] 一直是这个错误,困扰了我好多天,不知道哪里错了,增删改都可以就是 public List g
org.hibernate.hql.ast.QuerySyntaxException:3Q
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException:news is not mapped [from news] 一直是这个错误,困扰了我好多天,不知道哪里错了,增删改都可以就是 public List getNews(){ return sessionFactory.getCurrentSession().createQuery("from news").list(); } 创建一个查询不行,mapping文件也是自动生成的.

org.hibernate.hql.ast.QuerySyntaxException:3QException in thread "main" org.hibernate.hql.ast.QuerySyntaxException:news is not mapped [from news] 一直是这个错误,困扰了我好多天,不知道哪里错了,增删改都可以就是 public List g
你的数据库表名是不是new啊,因为这new是关键字啊,所以不行啊,你在mapping里这样加 :数据库名.表名,试试.追问:数据库 表名是news mapping是这样的 添加数据,修改,删除都可以 追问:之前用哪个admin为表名也是一样错 回答:怎么你的 实体类 对象跟mapping文件不对应的,hibernate都是对实体对象操作,并不是“from 表名”,你改成这样试试:return sessionFactory.getCurrentSession().createQuery("from New").list();