Hibernate's Criteria API
Hibernate has a Criteria API which allows you to dynamic build up filter conditions and set various join options. It is perfectly suited for flexible searches on entities, however there are areas in falls down in and the documentation is scarce. Criteria instances can be either created from the hibernate Session or a DetachedCriteria can be created for later execution or for passing into Spring's HibernateTemplate . The first thing that is explicitly mentioned is that references to properties can only be one deep, properties on child entities must be mapped via createAlias / createCriteria call. For example, the following will give a " org.hibernate.QueryException: could not resolve property: child.property of: com.example.model.Parent ". DetachedCriteria criteria = DetachedCriteria.forClass(Parent.class,"parent"); criteria.add(Restrictions.eq("parent.child.property", "somevalue"); Instead the child entity must be explicitly join by calling ...