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.  [ 3 posts ] 
Author Message
 Post subject: Web Page GridView Filters
PostPosted: Thu Aug 10, 2006 3:17 am 
Beginner
Beginner

Joined: Thu Jul 27, 2006 1:11 am
Posts: 21
I tried making a criteria and I can do all filters until I get to a many-to-many.

Example:
Object A contains 0-to-n object Bs. How do you filter a list of objects where object A contains a specific object B using expressions.

I played around with HQL and got it working with HQL but I thought that this sort of thing would be really common and could be done with expressions which are easier to use when you have heaps of if-elseif-elseif-elseif-...

string hql =
"select wi " +
" from WorkItem wi " +
" join wi.Components as wic " +
" where wic.Id = :componentId";

If it cannot be done with expressions, would the HQL above be the right way to achieve this.

Thanks in advance, Jono


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 13, 2006 3:32 am 
Beginner
Beginner

Joined: Thu Jul 27, 2006 1:11 am
Posts: 21
Just bumping this back to the top.

Since this is a pretty simple question I thought I would have received a reply. If you know the answer to my question I'd really like to hear from you because I can't continue with this section without an answer.

Thanks, Jono


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 13, 2006 9:14 am 
Beginner
Beginner

Joined: Thu Jul 27, 2006 1:11 am
Posts: 21
I have worked it out, the copy of the NHibernate docs I have must be pretty old or I missed the associations section because the online on has the section. You just have to create a criteria under the criteria.

Here is what I am using now:

Code:
IList workItems = base.Session.CreateCriteria(typeof(WorkItem))
    .CreateCriteria("Components")
        .Add(Expression.Eq("Id", componentId))
    .List();


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

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.