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 RE: Bug in 1:n Collection or...?
Date Thu, 08 Jul 2004 13:49:42 GMT
Some more interesting things (and this time I think it is a bug :) ):
The order in the class-descriptor is important! If I use:
 
<class-descriptor class="B" table="b">
  <field-descriptor name="id" ...>
  <field-descriptor name="refToA" id="7" .../>
  <field-descriptor name="someField"/>
  <reference-descriptor name="a".../>
</class-descriptor>

then the collection from class A containing the bs is empty again!
If I exchange the two fields "refToA" and "someField" it works
again (partially) and each object of A has exactly one B (not all,
but at least one :) ).

WDYT?

Carsten

> -----Original Message-----
> From: Carsten Ziegeler [mailto:cziegeler@s-und-n.de] 
> Sent: Thursday, July 08, 2004 1:30 PM
> To: ojb-dev@db.apache.org
> Subject: Bug in 1:n Collection or...?
> 
> 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
> 
> 


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