I have hibernate database with three model:
Article - which has is part of multiple categories (EDIT).
Category - which contains articles, and is part of an App
App - which has different categories
I want to select all articles which have a category of a specific app.
So I am trying to create something like:
find("ANY categories.app = ?", app).fetch();
Something like this worked for me with CoreData, but obvious not with JPA, and I don’t seem to be able to find how to do this.
Edit:
To clarify:
in Articles:
@ManyToMany
public List<Category> categories;
in Category:
@ManyToOne
public App app;
@ManyToMany(mappedBy = "categories")
public List<Article> articles;
in App:
@OneToMany(mappedBy = "app")
public List<Category> categories;
Read http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#queryhql