Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Customer {
- @Id
- @GeneratedValue
- private Long id;
- private String name;
- private Integer age;
- @OneToMany(mappedBy = "customer")
- List<CustomerOrder> customerOrders;
- }
- public class Product {
- @Id
- @GeneratedValue
- private Long id;
- private String name;
- private BigDecimal price;
- @ToString.Exclude
- @EqualsAndHashCode.Exclude
- @OneToMany(mappedBy = "product")
- List<CustomerOrder> customerOrders;
- }
- public class CustomerOrder {
- @Id
- @GeneratedValue
- private Long id;
- private String description;
- private Integer quantity;
- @ManyToOne(cascade = CascadeType.PERSIST)
- @JoinColumn(name = "customer_id")
- private Customer customer;
- @ManyToOne()
- private Product product;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement