Hibernate, mapping problem

Discussion in 'Java' started by robert@v-lo.krakow.pl, May 26, 2007.

  1. Guest

    Hello, i am trying to make my project for studies using hibernate but
    i've come across a problem i cant solve nor can found any help in
    tutorial. Well i have classes and mappings more less like this

    class X{
    map<AB, Y> ABs;
    map<AC, Y> ACs;
    }

    class Y{
    string info
    }

    class A {
    map <X, Y> Xs;
    }

    class AB estends A{
    string info2
    }

    class AC extends A{
    integer amount;
    }

    with mapping

    for X:
    <id ... column="X_id"...>

    <map name="ABs" inverse="true">
    <key column="X_id" not-null="true"/>
    <map-key-many-to-many column="A_id" class="AB" />
    <one-to-many class="Y"/>
    </map>

    <map name="ACs" inverse="true">
    <key column="X_id" not-null="true"/>
    <map-key-many-to-many column="A_id" class="AC" />
    <one-to-many class="Y"/>
    </map>

    for Y
    <id ... column="Y_id"...>
    ......

    for A, AB and AC
    <class name="A"....>
    <id... column="A_id"..>

    <map name="Xs">
    <key column="A_id" not-null="true"/>
    <map-key-many-to-many column="X_id" class="X" />
    <one-to-many class="Y"/>
    </map>

    <union-subclass name="AB".....>
    ......
    </union-subclass>

    <union-subclass name="AC".....>
    ......
    </union-subclass>
    </class>

    Then when i make:
    X x= new X(); Y y1...Y y2.... AB ab.... AC ac

    ab.Xs.add(x, y1);
    ac.Xs.add(x, y2);

    and then save all those objects to DB and after that load them then i
    see that x have 2 elements in both map ABs and ACs, and from neither
    of those maps its possible to benefit, since when iterate over
    elements of any of those collections always one is not found and an
    exception is thrown.

    Furthermore I can say that unfortunately movin Xs collection from
    class A to AB and AC (and mapping it twice) gives no effect.
     
    , May 26, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ilias Lazaridis
    Replies:
    0
    Views:
    1,758
    Ilias Lazaridis
    Dec 27, 2004
  2. Replies:
    7
    Views:
    4,657
    lars.egarots
    Jul 22, 2008
  3. garhone

    Hibernate mapping problem

    garhone, Aug 24, 2006, in forum: Java
    Replies:
    0
    Views:
    445
    garhone
    Aug 24, 2006
  4. ducnbyu
    Replies:
    2
    Views:
    6,200
    ducnbyu
    Sep 8, 2006
  5. Replies:
    1
    Views:
    697
    David Portabella
    Sep 9, 2007
Loading...

Share This Page