Hi again!

The problem has been fixed (I think). An upgrade to version 1.0.1 solved
it...

-----Original Message-----
From: Johan Gellner [mailto:[EMAIL PROTECTED] 
Sent: den 18 november 2004 14:42
To: [EMAIL PROTECTED]
Subject: Only one element is returned in m:n collections

Hi!

I'm new to OJB but have read most tutorials. I have a very strange
problem that I would like some help with. I am currently using OJB
1.0.rc5.

In the database I have three tables: PRODUCT, REFERER and PRODREFMAP.
The last table is an indirection table and contains only two columns:
PRODUCT_ID and REFERER_ID and thus implements the m:n mapping between
products and referrers.

I have created the Java classes for PRODUCT and REFERER, where
Referer.java contains a Collection named "products" and Product.java
contains a Collection named "referers".

The class-descriptor for Referer looks like this:
<class-descriptor

        class="somepackage.Referer"

        table="REFERER">

       . . .

       <collection-descriptor

         name="products"
 
collection-class="org.apache.ojb.broker.util.collections.ManageableArray
List"
         element-class-ref="somepackage.Product"
         auto-delete="false"
         auto-retrieve="true"
         orderby="name"
         sort="DESC"
         indirection-table="PRODREFMAP">
             <fk-pointing-to-this-class column="REFERER_ID"/>
             <fk-pointing-to-element-class column="PRODUCT_ID"/>
      </collection-descriptor>
</class-descriptor>

In my code, I successfully obtain an instance of Referer "r" from the
database through ODMG API. I then call r.getProducts() but the
Collection I get back only contains ONE Product element although the
database contains several Products for that Referer (as expressed in the
indirection table):

PRODREFMAP (table example)
----------------------------------------------
PRODUCT_ID     REFERER_ID
3002                           1
3003                           1
3004                           1
 
(but only product with id 3002 is returned)

Any idea why this is so?

Any help would be greatly appreciated!

Regards,

Johan Gellner


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to