Modelling a manyToMany relationship with attributes

Posted by Javi on Stack Overflow See other posts from Stack Overflow or by Javi
Published on 2010-05-31T11:38:04Z Indexed on 2010/05/31 11:42 UTC
Read the original article Hit count: 307

Filed under:
|
|

Hello,

I have a ManyToMany relationship between two classes, for instance class Customer and class Item. A customer can buy several items and an item can be bought by different customers. I need to store extra information in this relationship, for example the day when the item was bought. I wonder how is this usually modelled in JPA, cause I'm not sure how to express this in code. Do I have to create a new class to model all the attributes of the relationship and make a manyToMany relationship between the other classes or is a better way to do this?

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about best-practices