-->
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.  [ 5 posts ] 
Author Message
 Post subject: select distinct elements(...)
PostPosted: Wed Jun 09, 2004 3:56 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
I'm using hibernate 2.1 with MySql 4.0.12 nt
I have this query:
Quote:
"select distinct elements(rel.turma.detalhe) from Relatorio rel";

but it lists repeated elements; on other words, the distinct clause has no effect at all.
Can someone explain me, please, how can i rewrite the query so that it only returns distinct elements?
thanks i advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 5:54 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
"select elements(rel.turma.detalhe) from Relatorio rel";

then create a new hashset with the results

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 09, 2004 6:43 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
In first place thanks for your answer
anthony wrote:
"select elements(rel.turma.detalhe) from Relatorio rel";

then create a new hashset with the results

I'm sorry but i dont quite understand what i'm suposed to do after i make
Code:
Set novo = new HashSet();

after this what do i do? How can i have the distinct applied?
Can you pls help me further with any hint or idea?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 10, 2004 2:51 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Set novo = new HashSet(session.find(yourQuery);

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 10, 2004 6:30 am 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
Thanks for your help
i made:
Set novo = new HashSet(sess.find(query));
System.out.println("hashSet " + novo);
but keep getting repeated children.

My case is like this:
Parent A
Parent B
A's children:
a
b
c
B's children:
d
e
a
b

What i


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