equipment is not mapped 哈哈
程序员文章站
2022-04-28 16:38:16
...
public List allEquipment() {
Session session = MySessionFactory.getSession();
List list= new ArrayList();
Transaction ts = null;
try {
ts = session.beginTransaction();
String HQL = "select a from equipment as a order by a.id";
Query query = session.createQuery(HQL);
list = query.list();
ts.commit();
} catch (Exception e) {
ts.rollback();
System.out.println("查询所有,系统出现错误,原因为:");
e.printStackTrace();
}finally{
MySessionFactory.closeSession();
}
return list;
}
上面这个和下面这个 有什么不同呢?不过上面这个就是不能运行 报这个错误:equipment is not mapped
public List allEquipment() {
Session session = MySessionFactory.getSession();
List list = new ArrayList();
Transaction ts = null;
try {
ts = session.beginTransaction();
String HQL = "select a from Equipment as a order by a.id";
Query query = session.createQuery(HQL);
list = query.list();
ts.commit();
} catch (Exception e) {
ts.rollback();
System.out.println("查询所有,系统出现错误,原因为:");
e.printStackTrace();
}finally{
MySessionFactory.closeSession();
}
return list;
}
注意sql 语句
上面:String HQL = "select a from equipment as a order by a.id";
下面:String HQL = "select a from Equipment as a order by a.id";
这个家伙大小写不行啊。。。
上一篇: 基于thinkphp开发的新闻管理后台和api接口开发
下一篇: 怎么用python画花朵