-->
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: Mapping problem where 2 different classes have the same map
PostPosted: Sat May 26, 2007 1:59 pm 
Newbie

Joined: Wed May 23, 2007 10:06 am
Posts: 5
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.


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.