錯誤結果以下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