-->
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: Hibernate query using DISTINCT
PostPosted: Wed Jul 01, 2009 6:25 am 
Newbie

Joined: Wed Jul 01, 2009 6:19 am
Posts: 2
Is it possible to find a unique records based on a single filed.

eg: select distinct on (md.STRING01) md.STRING01, md.DATE01 , md.LONG01, md.LONG02, md.LONG03,md.LONG04
from app.MENU md

Can you pls suggest an equivalent hibernate query?

When tried distinct it checks distinct on all fileds. I want to check only one filed and return the latest one when duplictes occurs.


Top
 Profile  
 
 Post subject: Re: Hibernate query using DISTINCT
PostPosted: Wed Jul 01, 2009 6:37 am 
Newbie

Joined: Tue Jun 30, 2009 7:53 am
Posts: 4
Yes, it is possible.

Can you try following query:
select distinct(md.STRING01), md.DATE01 , md.LONG01, md.LONG02, md.LONG03,md.LONG04
from app.MENU md

_________________
Thanks,
Sanjeev Srinath


Top
 Profile  
 
 Post subject: Re: Hibernate query using DISTINCT
PostPosted: Wed Jul 01, 2009 8:14 am 
Newbie

Joined: Wed Jul 01, 2009 6:19 am
Posts: 2
Hi Sanjeev,

Thanks for your reply.

But it worked same as DISTINCT without filed name. DISTINCT(filedname) does not have any effect. So I got more than one field with same name, but unique when considering all fileds.


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.