Hello,
I'm having a hard time figuring out the correct way to configure a criteria query and I'm hoping someone can help me out or point in the right direction.
The annotated classes are below, but basically I have two entities: Account and ChartReview. A ChartReview has many reviewers (accounts) and an Account can have many ChartReviews. I'm trying to figure out how to define a criteria query that returns all ChartReviews where Account X is one of the reviewers. It has to be a criteria query because I'll be sorting the results by different Account properties at runtime.
Thanks for you help!
Hibernate version:
3.2
Mapping documents:
Code:
@Entity
@Table(name="accounts"
public class Account {
@ManyToMany
@JoinTable(
name="chart_reviewers",
joinColumns=
@JoinColumn(name="account_id"),
inverseJoinColumns=
@JoinColumn(name="chart_review_id")
)
private List<ChartReview> chartReviews;
// Other mapped properties like id, etc
}
@Entity
@Table(name="chart_reviews")
public class ChartReview {
@ManyToMany
@JoinTable(
name="chart_reviewers",
joinColumns=
@JoinColumn(name="chart_review_id"),
inverseJoinColumns=
@JoinColumn(name="account_id")
)
private List<Account> reviewers;
// Other mapped properties like id, etc
}
Name and version of the database you are using:
Oracle 10gR2