使用Hibernate 进行查询错误:
In the following code I am trying to get a List of Products which contains all the products in the database:
org.hibernate.Transaction tx = session.beginTransaction(); products = session.createSQLQuery("SELECT * FROM Products").list(); if(products.size() > 0) { return products; } return null;
解决方法一:
List<Products> list = session.createCriteria(Products.class).list();
解决方法二:
(List<Products>)session.createSQLQuery("SELECT * FROM Products").addEntity(Products.class).list();
时间: 2024-10-18 05:30:36