-->
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.  [ 2 posts ] 
Author Message
 Post subject: Criteria Query with DISTINCT with Subquery
PostPosted: Fri Apr 16, 2010 1:09 am 
Newbie

Joined: Fri Apr 16, 2010 12:43 am
Posts: 2
Starting with Ayende's article at
http://ayende.com/Blog/archive/2009/05/ ... mples.aspx
and using the example Criteria Query:
Code:
var blogs = s.CreateCriteria<Blog>()
    .Add(Subqueries.PropertyIn("id",
        DetachedCriteria.For<Post>()
            .SetProjection(Projections.Property("Blog.id"))
            .CreateCriteria("User")
            .Add(Restrictions.Eq("Username","Ayende"))
        ))
    .List<Blog>();

I have this working OK. Now I'd like to extend it to perform a DISTINCT query on some columns in the result set and I haven't been able to figure it out. Can anyone help?

Thanks
Steve


Top
 Profile  
 
 Post subject: Re: Criteria Query with DISTINCT with Subquery
PostPosted: Fri Apr 16, 2010 4:08 am 
Newbie

Joined: Fri Apr 16, 2010 12:43 am
Posts: 2
Figured it out. Basically all it needed was to use a Distinct Projection on the Criteria created for the session.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.