-->
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: carthesian product in OneToMany relation
PostPosted: Thu Oct 08, 2009 5:43 am 
Newbie

Joined: Wed Jun 21, 2006 9:48 am
Posts: 12
Location: Germering
Hi folks,

I need help for I get an karthesian product of data. The database structure is defined as:

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



The result I would expect by the mapping below is for i.e. 4 searchvalues:
a1->b1, b2, b3
a2->b4, b5
a3-><empty>
a4->b1, b2, b3


What I get is:
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





The mapping ...
to gather gather data from the given ER. But only unidirectional for
there is no need to find the valu of A from an Instance of B.

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;
    }

}



Any idea?


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.