Hibernate rowcount method: returns the number of records that meet the condition

rowCount()

Example

Criteria criteria = session.createCriteria(UserForm.class);  //创建Criteria对象
criteria.add(Restrictions.eq("username","sk"));  //设置查询条件
criteria.setProjection(Projections.rowCount());  //查询结果返回的行数
int value = (Integer)criteria.uniqueResult();  //获取查询结果
System.out.println("记录数:"+value);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>