I have the following tables (simplified):
Product(Id, Name)
OrderItem(Id, ProductId)
... which belong to the following classes:
Product {Id, Name}
OrderItem {Id, Product (many-to-one)}
I need the (N) Hibernate syntax to retrieve the products that appear in the Order.
SQL will look something like this:
select *
from Product
where exists (
select *
from OrderItem
where OrderItem.ProductId = Product.Id)
How to create criteria?
source
share