-->
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: @OneToMany redundante Objekte im ergebnis
PostPosted: Wed May 31, 2006 12:26 pm 
Newbie

Joined: Wed May 31, 2006 12:16 pm
Posts: 1
Hallo @ all,

ich verwende Hibernate mit java 5 anotations + spring.

Ein Kunde hat mehrere Konditionen:

@Entity
@Table (name="kd")
public class KdEntity

@OneToMany (mappedBy="kunde", fetch=FetchType.EAGER)
protected Set <KdKonditionEntity> konditionen;


Hier der Eintrag in der Kondition:
@Entity
@Table(name="c_kd_kond")
public class KdKonditionEnt

@ManyToOne
@JoinColumn(name="kd_id", unique=true)
protected KdEntity kunde;

wenn ich jetzt alle Kunden hole, kommen die Kunden, die Konditionen haben, mehrmals im Ergebnis vor.

Die SQL query die Hibernate generiert schaut so aus:
select this_.id as id6_1_, this_.name as name6_1_, konditione2_.kd_id as kd5_3_, konditione2_.id as id3_, konditione2_.id as id2_0_, konditione2_.kd_id as kd5_2_0_, konditione2_.art as art2_0_, konditione2_.glt_von as glt3_2_0_, konditione2_.glt_bis as glt4_2_0_ from kd this_ left outer join c_kd_kond konditione2_ on this_.id=konditione2_.kd_id;

gibts irgend einen Parameter, damit er ein group by oder distinct macht, sodass die kunden nicht mehrmals vorkommen?

Vielen Dank


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 06, 2006 7:10 am 
Newbie

Joined: Thu Nov 10, 2005 7:21 pm
Posts: 4
Location: Germany
Hallo,

ich hatte ein ähnliches Problem und ich habe es mit setFetchMode("xx", FetchMode.SELECT) lösen können. Leider hat sich mir bisher nicht der Hintergrund erschlossen...sprich ich verstehe nicht warum...würde es aber gerne...

MfG
Karl Heinz


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.