-->
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: many-to-many and multiple objects
PostPosted: Thu Jul 14, 2005 12:54 pm 
Beginner
Beginner

Joined: Mon Jun 20, 2005 3:14 pm
Posts: 33
Hi,

I'm trying to map 2 tables and an association table:

OCORRENCIA
----------------
A
B

CESTA
---------------
1
2

OCORRENCIA_CESTA
-------------------------
A 1
A 2
B 1

class Ocorrencia {
String name;
List<Cesta> cestas;
}

class Cesta {
int codigo;
List<Ocorrencia> ocorrencias;
}

Using "from Ocorrencia as o left join fetch o.cestas" Hibernate returns:

A [1,2]
A [1,2]
B [1]

Why A [1,2] apper 2 times?

Thanks,

Andre


Top
 Profile  
 
 Post subject: Re: many-to-many and multiple objects
PostPosted: Thu Jul 21, 2005 10:09 am 
Regular
Regular

Joined: Mon Apr 25, 2005 5:36 am
Posts: 103
ad-rocha wrote:
Hi,

I'm trying to map 2 tables and an association table:

OCORRENCIA
----------------
A
B

CESTA
---------------
1
2

OCORRENCIA_CESTA
-------------------------
A 1
A 2
B 1

class Ocorrencia {
String name;
List<Cesta> cestas;
}

class Cesta {
int codigo;
List<Ocorrencia> ocorrencias;
}

Using "from Ocorrencia as o left join fetch o.cestas" Hibernate returns:

A [1,2]
A [1,2]
B [1]

Why A [1,2] apper 2 times?

Thanks,

Andre



I have the same pb, do you have find the solution????


Top
 Profile  
 
 Post subject: Re: many-to-many and multiple objects
PostPosted: Thu Jul 21, 2005 10:23 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
This has been answered many times in this forum.

http://forum.hibernate.org/viewtopic.ph ... esults+set

Anthony's(one of the Hibernate guys) posted this answer to the above topic.

join has the same meaning as SQL join, so just use
Set results = new HashSet(query.list()) if you don't want duplicate results.



If you need to order the results, use a TreeSet instead of hashset.


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.