[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ojb-user
Subject:    Re: Using composite foreign keys in 1:N relationship
From:       Armin Waibel <arminw () apache ! org>
Date:       2005-12-11 16:14:18
Message-ID: 439C505A.5070308 () apache ! org
[Download RAW message or body]

Hi,

Aleks wrote:
> 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 )
>  
...
>  
> 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?
>  

AFAIK it's the order of declaration. If the PK field-descriptor 
declaration in ProductGroup is
int groupId
int groupNum and
int groupKey

then in Article the FK declaration have to use the same order.

regards,
Armin

> Thank you for your help.
>  
> 

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic