Many to Many CMR with an attribute  
Author Message
dominique.prunier





PostPosted: 2005-2-2 5:41:00 Top

java-programmer, Many to Many CMR with an attribute Hi,

I have a db scheme where i have a Many to Many relation but i have to
store an attribute in the mapping table. Then, i thought i could
transform my N-N relation in two 1-N relation, explicitely creating the
mapping table with my own attribute but this table has no primary key
(actually it should be the composition of the two foreign keys). Is it
possible to create an Entity where primary keys is the composition of 2
CMR fields or is there another way to do something like that ?

The db :

Supplier(id, name, ...) <-*--(quantity)--*-> Item(id, name, ..)

which is actually

Supplier(id, name, ...) <-1--*-> Supplier_Item(sup_id, item_id,
quantity) <-*--1-> Item(id, name, ...)


Thanks.

 
Marek Lange





PostPosted: 2005-2-4 23:30:00 Top

java-programmer >> Many to Many CMR with an attribute email***@***.com wrote:

> I have a db scheme where i have a Many to Many relation but i have to
> store an attribute in the mapping table. Then, i thought i could
> transform my N-N relation in two 1-N relation, explicitely creating the
> mapping table with my own attribute but this table has no primary key
> (actually it should be the composition of the two foreign keys). Is it
> possible to create an Entity where primary keys is the composition of 2
> CMR fields or is there another way to do something like that ?

You have to write an entity bean for the mapping table if you want to
access the additional attribute in your code. The primary key is then a
composite one consisting of the two foreign keys (own PK class
necessary). No problem to do that.

-marek