Modeling manyToMany relationships with attributes

I have a ManyToMany relationship between two classes, for example class Customer and class Item. A customer can buy several items, and a product can be purchased by different customers. I need to store additional information in this relationship, for example, on the day the item was purchased. I wonder how this is usually modeled in JPA, because I'm not sure how to express this in code. Should I create a new class to model all the attributes of a relationship and create manyToMany relationships between other classes or is this the best way to do this?

thank

+2
source share
3 answers

"--" .

+3

, .

+1

As you said yourself, the right way is to create a new class with additional attributes.

+1
source

All Articles