数据库中表名是:book,数据库表名不区分大小写的
之后我在hibernate 使用book,
String sql="from book"; Query query=session.createQuery(sql); Listbooks=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" />