I have the following classes:
public class Folder{
private Set<Documents> documents;
private Set<Clip> clips;
}
public class Clip{
private Owner owner;
}
I need to find list of nice documents in yellow folders that have owners of clips in those folders, whose names are like search string. Something like this (not working):
Criteria criteria = session.createCriteria(Document.class);
criteria.add(Restrictions.eq("isNice", 1));
criteria.createCriteria("folder").add(Restrictions.eq("isYellow", 1));
criteria.createCriteria("clips");
criteria.createCriteria("owner").add(Restrictions.like("name", search));
List documents = criteria.list();
How do i create criteria for HashSet? Or
- maybe i should use hql query
- Maybe I could edit just
List documents, removing bad entries? - Is it even possible with criteria?
- If not what's the another way?
edit. I've found this snippet of code:
List cats = sess.createCriteria(Cat.class)
.createCriteria("kittens", "kt")
.add( Restrictions.eq("name", "F%") )
.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP)
.list();
Iterator iter = cats.iterator();
while ( iter.hasNext() ) {
Map map = (Map) iter.next();
Cat cat = (Cat) map.get(Criteria.ROOT_ALIAS);
Cat kitten = (Cat) map.get("kt");
}
but i cant understand what exactly it does. Whats resultTransformer?
Please, any advice or tip would help so much! Thanks!