我有三个模型的hibernate数据库:
Article - which has is part of multiple categories (EDIT).
Category - which contains articles, and is part of an App
App - which has different categories
我想选择所有具有特定应用类别的文章。 所以我想创建类似的东西:
find("ANY categories.app = ?", app).fetch();
这样的东西对我来说对CoreData有用,但显然没有用JPA,我似乎无法找到如何做到这一点。
编辑: 澄清: 在文章中:
@ManyToMany
public List<Category> categories;
分类中的:
@ManyToOne
public App app;
@ManyToMany(mappedBy = "categories")
public List<Article> articles;
在App中:
@OneToMany(mappedBy = "app")
public List<Category> categories;
答案 0 :(得分:0)
select a from Article a where a.category.app = ?
阅读http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#queryhql