select count(*) from table where
hql : 其中table 表示表对应的类 也就是你要查询的数据库表映射的类名 where 直接 类.属性
例:
public class Student{
private String id;
private String name;
// getset 省略
}
比如这个类映射的是数据库的 tb_student 表
那么 hql 你可以直接写
select count(*) from Student s where s.id = '' and s.name=''
where后面其实和sql差不多不过是属性罢了 注意和实体类里面的属性大小写要写好
然后 session.createQuery(hql);
session.createQuery("需要执行的hql");或session.createSqlQuery("需要执行的sql");
session.createQuery("需要执行的hql"); 这种是用hiberante hql语句
如果你要用 sql 那你就只能或得connection连接 用jdbc写了