欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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";
这个家伙大小写不行啊。。。

相关标签: SQL