hibernate一些方法说明

distinct :查询时取重复数据的一条,并排序,最好喝order by一起使用
Integer count=(Integer)session.createQuery("select count(distinct c.name) from Customer c").uniqueResult();

createFilter:对现有已持久化的集合数据进行过滤操作。如排序,取top
List result=session.createFilter(customer.getOrders(),"where this.price>100 order by this.price").list();
List result=session.createFilter(customer.getOrders(),"where this.price>100 order by this.price").setFirstResult(10).setMaxResult(10).list();

你可能感兴趣的:(Hibernate)