jboss 3.2.2 cmp2 many-to-one relation bug?
joergs Nov 21, 2003 7:45 AMHi,
i've got a problem with the Many to One Unidirectional relationship.
I hava a Bean A: KalenderSerienElement and a Bean B: Betriebsart
Many Beans Type A share the same Beans B, B doesn't know of the A's.
I'm jusing jboss 3.2.2 on winxp and j2sdk 1.4.2 , with ms-sql2000 std jdbc driver, not tx-enabled.
The ejb-jar.xml relation part is:
<ejb-relation >
<ejb-relation-name>SerienElementBetriebsart</ejb-relation-name>
<ejb-relationship-role >
<ejb-relationship-role-name>jedes SerienElement hat eine Betriebsart</ejb-relationship-role-name>
Many
<relationship-role-source >
<ejb-name>KalenderSerienElement</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>betriebsArt</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role >
<ejb-relationship-role-name>Eine Betriebsart gehoert zu vielen Serienelementen</ejb-relationship-role-name>
One
<relationship-role-source >
<ejb-name>Betriebsart</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
The Problem is, when i try to set a Bean A in relation to a bean B, all other bean a's in relation to that specific bean b lose their relation to that
so:
Bean a1 -> b1
Bean a2 -> b2
Bean a3 -> null
when i try to set a3-> b1, a1 loses its relation to b1:
Bean a1 -> null
Bean a2 -> b2
Bean a3 -> b1
It behaves excatly as one to one relationship, where every b should only have be in relation to one a, and vice-versa.
Here the code that chould set the relation in bean a:
try{
Context ctx=new InitialContext();
//Find the correct Bean B
BetriebsartLocal betriebsartLoc=((BetriebsartLocalHome)ctx.lookup("BetriebsartLocal")).findByPrimaryKey(new Integer(serienDO.getBetriebsartDO().getId()));
//Set the relation
this.setBetriebsArt(betriebsartLoc);
}
After this code runs, every Bean A in reference to the found bean b, betriebsartLoc, looses its relation.
Is this a bug? Am i missing somewhat? what can i do to avoid it? i don't want to code in in sql with jdbc, for interoperablilty (?).
Thanks for your help in advance
Joerg