hql 的 count(*)

使用hibernate session:

String hql = "select count(*) from Category c where c.parent = 1";
Query q = session.createQuery(sql);
System.out.println(q.uniqueResult());

如果sql使用出错:
String sql = "select count(*) from t_category c where c.PID= 1";
                  Query q = session.createQuery(sql);
System.out.println(q.uniqueResult());
~://
Caused by: java.sql.SQLException: Column '' not found.

你可能感兴趣的:(sql,C++,c,Hibernate,C#)