db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@s-und-n.de>
Subject Bug in 1:n Collection or...?
Date Thu, 08 Jul 2004 11:29:34 GMT
I'm trying to get a simple 1:n relationship working, here is
the (stripped) mapping:

<class-descriptor class="A" table="a">

 <field-descriptor name="id" column="ID" jdbc-type="INTEGER" 
                   primarykey="true" autoincrement="true"/>

 <collection-descriptor name="bs"
               element-class-ref="B"
               auto-retrieve="true">
   <inverse-foreignkey field-ref="refToA"/>
 </collection-descriptor>

</class-descriptor>

<class-descriptor class="B" table="b">

 <field-descriptor name="id" column="ID" jdbc-type="INTEGER" 
                   primarykey="true" autoincrement="true"/>

 <field-descriptor name="refToA" column="reftoa"
                          jdbc-type="INTEGER"
                          access="anonymous" />

 <reference-descriptor name="a"
                          class-ref="A">
    <foreignkey field-ref="refToA"/>
 </reference-descriptor> 

</class-descriptor>

When getting all As using a query, the collection of each A containing Bs
is always empty. The interesting thing is, that an SQL statement to fetch
the Bs is processed and the Bs are loaded. But somehow they are not
added to the collection.

The reverse, fetching B works. They have the correct relation set back to
an A object.

Now for the interesting part :) If I use:
   <inverse-foreignkey field-id-ref="7"/>

and give the "refToA" field the id "7" then the collection of A is not
empty but contains the first associated B but never all!

So, question is: is this a bug or am I just too stupid and did oversee
something?

I tried this with 1.0.0 and the first part with current CVS.

Carsten 

Carsten Ziegeler 
Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.net/weblogs/rael/


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message