用DetachedCriteria避免一对多时的重复数据

阅读更多
1. DetachedCriteria criteria = DetachedCriteria.forClass() // 父对象
2. 将所有查询条件写进去
3. DetachedCriteria rootCriteria = DetachedCriteria.forClass() // 父对象
4. criteria.setProjection(Projections.distinct(Projections.projectionList().add(Projections.alias(Projections.property("id"), "id")))); // id 是distinct对象

5. rootCriteria.add(Subqueries.propertyIn("id", criteria));

你可能感兴趣的:(用DetachedCriteria避免一对多时的重复数据)