JPA i Hibernate

0

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ę?

1

Podaj więcej szczegółów. Query jak wygląda - czy to SQL czy JPA -QL (może Ci się zamotały???).

Poza tym jak piszesz:
produkt o danej nazwie i danej kategorii oraz danego producenta

to prosze

//tylko prosze nie chrzanić, że jest nie wydajne - strzelam ,że tam niegdy nie będzie więcej niż 100 wierszy 
private List<Product> gimmeBabyProductsLike(final String productName, final ProductCategory category, final Maker maker) {
    return maker.getProduct().stream()
         .filter( p-> p.getProductName().equals(productName))
         .filter( p -> p.getCategory().equals( category))
         .collect(Collectors.toList());

}

1 użytkowników online, w tym zalogowanych: 0, gości: 1