Hi,
I have 2 tables named Forms and FormPages. Forms have one to many relationship to FormPages table. The Forms entity can have multiple FormPages entities in it. I need to retrieve all Forms; and the FormPages collection should be filtered w.r.t a field named 'isloaded' in the FormPages table.
I have written the following code:
Criteria crt=HibernateUtil.getCurrentSession().createCriteria(Forms.class);
crt.createCriteria("formpageses");
.add((Expression.eq("isloaded","Y")));
crt.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
List<Forms> formslist=new ArrayList<Forms>(crt.list());
Iterator iter = formslist.iterator();
while(iter.hasNext()){
Map map = (Map) iter.next();
Forms formsEntity=(Forms)map.get(Criteria.ROOT_ALIAS);
}
But this doesn't filter the FormPages collection. Also, the Forms collection repeats based on the number of FormPages collection in it.
Does anyone know how to do this?
Thanks in advance
Jency
|