-->
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: DetachedCriteria & Distinct on a table not just a proper
PostPosted: Sat Apr 29, 2006 9:04 pm 
Newbie

Joined: Sun Mar 05, 2006 7:36 pm
Posts: 4
Hi

I try to figure out how to use the distinct projection object with the DetachedCriteria on a table and not just a column(property) of a table.

For a property it would be like this:

Code:
Criteria cr = session.createCriteria("hr.klopa.domain.FoodItem").setProjection(Projections.distinct(Projections.property("name")));


but how can I use the destinct feature on the whole table and not just on a property e.g. select distinct * from table

Any help is very much appreciated

Cheers
Rolf


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 02, 2006 12:21 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yep, there are a couple of ways. Projections.property("this") is the equivalent of * in that situation, I think. You should end up with "distinct col1 as col11_, col2 as col21_, ..." in your generated SQL, so it'll be more verbose than "distinct *" but completely analagous.

If that doesn't work, this should:
Code:
Projections.sqlProjection("distinct *", String[] {""}, Type[] {Hibernate.INTEGER})

_________________
Code tags are your friend. Know them and use them.


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.