Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public class Customer {
  2.  
  3. @Id
  4. @GeneratedValue
  5. private Long id;
  6.  
  7. private String name;
  8. private Integer age;
  9.  
  10. @OneToMany(mappedBy = "customer")
  11. List<CustomerOrder> customerOrders;
  12.  
  13. }
  14.  
  15. public class Product {
  16.  
  17. @Id
  18. @GeneratedValue
  19. private Long id;
  20. private String name;
  21. private BigDecimal price;
  22.  
  23. @ToString.Exclude
  24. @EqualsAndHashCode.Exclude
  25. @OneToMany(mappedBy = "product")
  26. List<CustomerOrder> customerOrders;
  27. }
  28.  
  29. public class CustomerOrder {
  30.  
  31. @Id
  32. @GeneratedValue
  33. private Long id;
  34. private String description;
  35. private Integer quantity;
  36.  
  37. @ManyToOne(cascade = CascadeType.PERSIST)
  38. @JoinColumn(name = "customer_id")
  39. private Customer customer;
  40.  
  41. @ManyToOne()
  42. private Product product;
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement