Created
December 30, 2013 11:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Mother> find(String aProperty){ | |
Session session = getSession(); // Create hibernate session | |
Criteria motherCrit = s.createCriteria(Mother.class); | |
// Create sub query | |
DetachedCriteria childListCrit = DetachedCriteria.forClass(Child.class); | |
childListCrit.add(Restrictions.eq("aProperty", aProperty)); | |
childListCrit.setProjection(Projections.distinct(Projections.property("mother.id"))); | |
motherCrit.add(Subqueries.propertyIn("id", childListCrit)); | |
return motherCrit.list(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment