title: JPA Relationship Order and Product
body: <p>Consider the following scenario. 
  There are Products (eg. Cakes, Cup cakes, muffins and etc) with fields "id", "name", "price". 
  An order can have multiple products with quantities. In a relational DB it should be 3 tables. Order, Product and Order_Product (with orderId and productId as primaryKey and a "quantity" column). But I am not sure about the relationship in JPA for this scenario.</p>
  
  <p>There relationship between Order and Product needs to be One-To-Many. But am confused where column "quantity" (number of products) should come. </p>
  
  <p>Order Entity</p>
  
  <pre><code>@Entity
  public class MyOrder implements Serializable
  {
      @Id
      @GeneratedValue
      private Long Id;
  
      @OneToMany(mappedBy = "product")
      private Set&lt;Product&gt; product;
  }
  </code></pre>
  
  <p>Product Entity</p>
  
  <pre><code>@Entity
  public class Product implements Serializable
  {
      @Id
      @GeneratedValue
      private Long id;
  
      private String name;
  
      private double unitPrice;
  }
  </code></pre>
  
  <p>Thank you.</p>