Witam, mam problem z JPA. A mianowicie w encjach mam releacje oneToMany i w bazie danych wszystko super się robi:
(wygląda to mniej więcej tak)
@Entity
public class Maker {
@Id
@GeneratedValue
private int id;
@Column(name="MakerName")
private String makerName;
@OneToMany(mappedBy = "maker")
private List<Product> product;
public void setMakerName(String MakerName) {
this.makerName = MakerName;
}
public String getMakerName() {
return makerName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<Product> getProduct() {
return product;
}
public void setProduct(List<Product> product) {
this.product = product;
}
}
druga encja:
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name="ProductName")
private String productName;
@Column(name="Category")
private ProductCategory category;
@Column(name="Quantity")
private int quantity;
@Column(name = "Price")
private double price;
@ManyToOne
@JoinColumn(name="Maker_id")
private Maker maker;
@Column(name="ExpirationDate")
private GregorianCalendar date;
public GregorianCalendar getDate() {
return date;
}
public void setDate(GregorianCalendar date) {
this.date = date;
}
public Maker getMaker() {
return maker;
}
public void setMaker(Maker maker) {
this.maker = maker;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public ProductCategory getCategory() {
return category;
}
public void setCategory(ProductCategory category) {
this.category = category;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
i teraz jak chce wyświetlić produkt o danej nazwie i danej kategorii oraz danego producenta wywala mi błąd że w tabeli product nie istnieje kolumna "Maker_id"
Jakieś pomysły dlaczego tak się dzieję?