HQL语法结构(update/delete子句为Hibernate3引入的新特性)
[select/update/delete]
[from...]
[where...]
[group by...[having...]]
[order by...]
hql = "SELECT DISTINCT user.admin FROM User as user";
DISTINCT表示去掉重复值。
在testCase的增加表中,增加product和module字段时可用此关键字。
hql = "SELECT COUNT(*) FROM User";
hql = "SELECT AVG(user.age) FROM User as user";
hql = "SELECT UPPER(user.name) FROM User as user";
hql = "FROM User as user WHERE user.name is not null";
UPDATE User SET name="vivian" WHERE name="peggy";//没有给User类起别名
DELETE User WHERE name="peggy";
Criteria Query和Query接口提供了两个方法,用于完成分页
setFirstResult(0); //从第0条取数据
setMaxResult(10); //共取10条记录
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ForWayfarer/archive/2008/09/06/2889267.aspx