I have entities Author and Product. Author has multiple products. So they have relationship One-to-many. I want to add connection One-to-many Category-Product. so Products will have 2 many-to-one relationships: with Author and Category. How do i do it?
@Entity
public class Author {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "authors_generator")
@SequenceGenerator(name = "authors_generator", allocationSize = 1)
private Long id;
private String firstName;
private String lastName;
private String job;
@OneToMany(mappedBy = "author", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JsonManagedReference
private List<Product> products = new ArrayList<>();
@Entity
@Table(name = "products")
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "products_generator")
@SequenceGenerator(name = "products_generator", allocationSize = 1)
private Long id;
private Long idOfAuthor;
private String name;
private int height;
private int width;
private String color;
private String description;
private String image;
@JsonBackReference
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "authors_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Author author;

