错误结果以下java
Exception in thread "main" org.hibernate.hql.internal.ast.QuerySyntaxException: news is not mapped [from news]
。。。。session
。。。。
at com.zh.hibernate.hellword.NewsHOLTest.main(NewsHOLTest.java:26)app
错误缘由:from对应的应该是实体类的名字,而不是数据表的名字。书写过程当中我把它视为数据表的名字因此才出错。spa
修改后:Query qy = session.createQuery("from News");
List<News> list = qy.list();hibernate
将其改为实体类的名字后就对了。io
表面上看起来会以为是大小写的区分,实际上,是对应了表名和实体类名的区分。不定的其中原理即便碰对了相信也不会明白其中原因。ast