-->
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.  [ 1 post ] 
Author Message
 Post subject: Karthesisches Produkt bei einer OneToMany Relation
PostPosted: Thu Oct 08, 2009 5:49 am 
Newbie

Joined: Wed Jun 21, 2006 9:48 am
Posts: 12
Location: Germering
Hallo zusammen,

ich brache dringend eine Idee, warum ich bei dem Mapping unten ein Karthesisches Produkt bekomme.
Hier erstmal die DB-Struktur:

ER-Diagramm
Code:
+---+    +---+
| A |+--<| B |
+---+    +---+



Bei 4 Filter-Werten erwarte ich folgendes Ergebnis:
a1->b1, b2, b3
a2->b4, b5
a3-><empty>
a4->b1, b2, b3


Ich bekomme allerdings das hier:
a1->b1, b2, b3
a1->b1, b2, b3
a1->b1, b2, b3
a2->b4, b5
a2->b4, b5
a3-><empty>
a4->b1, b2, b3
a4->b1, b2, b3
a4->b1, b2, b3





Das Mapping ...
um Daten aus der gegebenen DB-Struktur zu holen. Ich benötige die Daten nur
unidirektional, da es keine notwendigkeit gibt von B auf Daten der
Klasse A zuzugreifen


Code:
@Entity
public class A implements IofA {

    @Id
    private Long key1;
   
    privtae Long searchValue;

    @OneToMany(mappedBy = "key1", fetch = FetchType.EAGER)
    private List<B> finance;
   
    // further members, getter and setter
   
}

Code:
@Entity
@IdClass(value = B_PK.class)
public class B implements IofB  {

    /**
     * part of the primary key.
     * This value is the same an the PK of class A
     */
    @Id
    private Double key1;
   
    @Id
    private Short key2;

    @Id
    private Character key3;
   
    // further member, getter and setter ...
}

Code:
/**
* definition of the composed PK of class B
*/
@Embeddable
public class B_PK implements Serializable {


    @Id
    private Double key1;

    @Id
    private Short key2;

    @Id
    private Character key3;
   
    // getter and setter named exactly the same as in B
}

The repository ...
Code:
/**
* The repository to gather data:
*/
public class Hibernate3_RiskRepository {

    public List<IofA> findData(List<Long> searchvalues) {
        LOG.debug("Filtered searchValues's are: " + searchvalues);
        Criterion criterion = Restrictions.in("searchValue", searchvalues);
        List<IofA> list = super.findByCriteria(criterion, (Order[]) null);
        return list;
    }

}



Kann jemand helfen?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.