hibernate xx(tableName) is not mapped

数据库中表名是:book,数据库表名不区分大小写的

之后我在hibernate 使用book, 

 


String sql="from book"; Query query=session.createQuery(sql); List<Book> books=query.list(); for(Book book1:books) { System.out.println(book1.getName()+book1.getAuthor()+book1.getPrice()+book1.getId()); }

 报错:


Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: book is not mapped [from book]

之后检查map 配置,book mapping 后是Book,将book->Book就好用了

 

<hibernate-mapping>
<class name="data.Book" table="book" catalog="study">
<id name="id" type="java.lang.Integer">
<column name="id" />

 

 

posted @ 2014-01-05 16:22  to be crazy  阅读(1612)  评论(0编辑  收藏  举报