-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: filtering collections
PostPosted: Mon May 28, 2007 4:03 am 
Newbie

Joined: Fri Apr 20, 2007 5:30 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.