1
我有這個類:HQL如何加入三個表
@Entity
public class Category {
private Long Id;
private String name;
private String description;
private List<Product> products;
}
@Entity
public class Inventory {
private Long id;
private Product product;
private int quantity;
}
@Entity
public class Product {
private Long productId;
private String name;
}
我想給出的類別編號清單。我試圖用這
return session.createQuery("select i from Inventory i, Category c join c.Products p outer join i.product = p WHERE c.Id=?")
.setParameter(0, categoryId).list();
我真的很困惑,請幫助。謝謝。
有你嘗試使用標準?他們從數據庫中提取數據更好。 –
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querycriteria.html –
謝謝@BenjaminDale我找到了答案。 – Clark