For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > February 2005 > Many to Many CMR with an attribute









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Many to Many CMR with an attribute
dominique.prunier@gmail.com

2005-02-01, 8:58 pm

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

2005-02-04, 8:57 pm

dominique.prunier@gmail.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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com