Hi,
 
I'm new to OJB and have been looking at the tutorials and examples and
so far all looks good apart from an example I found that works well but
I am not sure how it would work in the case of composite keys.  The
example is the 1:N example between Product and Article tables.
(http://db.apache.org/ojb/docu/guides/basic-technique.html )
 
Here is the mapping file:
 
<!-- Definitions for org.apache.ojb.broker.ProductGroup -->
 <class-descriptor
    class="org.apache.ojb.broker.ProductGroup"
    table="Kategorien"
 >
    <field-descriptor
       name="groupId"
       column="Kategorie_Nr"
       jdbc-type="INTEGER"
       primarykey="true"
       autoincrement="true"
    />
    <field-descriptor
       name="groupName"
       column="KategorieName"
       jdbc-type="VARCHAR"
    />
    <field-descriptor
       name="description"
       column="Beschreibung"
       jdbc-type="VARCHAR"
    />
    <collection-descriptor
       name="allArticlesInGroup"
       element-class-ref="org.apache.ojb.broker.Article"
       orderby="articleId"
       sort="DESC"
    >
       <inverse-foreignkey field-ref="productGroupId"/>
    </collection-descriptor>
 </class-descriptor>
 
 
As can be seen there, productGroupId is the foreign key used in the
Article table (I haven't actually posted the Article mapping). This
works fine since, as you can see, the Product table has one primary key,
namely 'groupId'. What I was wondering is how would I perform this
example if the Product table had a composite primary key consisting of
let's say:
 
*         int groupId
*         int groupNum and
*         int groupKey
 
 
The problem is that they're all of the same type so how can it be known
which parts of the foreign key in Article are "pointing" to which parts
of the primary key in Product?
 
Thank you for your help.
 

Reply via email to