Estão da seguinte forma:
package br.org.cesar.Desafio.entity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import br.org.cesar.Desafio.entity.Category;
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String name;
private double price;
@ManyToOne
private Category category;
@ManyToMany(mappedBy = "products")
private List<Orders> orders = new ArrayList<>();
public Product() {
}
public Product(long id, String name, double price, Category category) {
this.id = id;
this.name = name;
this.price = price;
this.category = category;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
}
package br.org.cesar.Desafio.entity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import br.org.cesar.Desafio.entity.Product;
public class Category {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String name;
@OneToMany(mappedBy = "category")
private List<Product> products = new ArrayList<>();
public Category() {
}
public Category(long id, String name, List<Product> products) {
this.id = id;
this.name = name;
this.products = products;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
}