Hibernate distinct method: set the uniqueness of query results
•
Java
distinct(Projection proj)
Example
Criteria criteria = session.createCriteria(UserForm.class); //获取Criteria对象 criteria.setProjection(Projections.distinct(Projections.property("username"))); //定义去掉重复值查询 Iterator it = criteria.list().iterator(); //获取查询结果迭代器 while(it.hasNext()){ //循环遍历查询结果 System.out.println("用户名:"+it.next()); }
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
二维码