I have 2 POJO classes in Java, Answer and Collaborator, in a many-to-many relationship.
class Answer {
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "ANSWERS_COLLABORATORS", joinColumns = { @JoinColumn(name = "aid") }, inverseJoinColumns = { @JoinColumn(name = "cid") })
private Set<Collaborator> collaborators = new HashSet<Collaborator>(0);
}
Class Answer
has a set of Collaborator
, but a Collaborator
doesn't keep a set of Answer
.
What I need to do from Hibernate CriteriaQuery
is to find the collaborators for an answer given by id.
I have already done this with Hibernate Criteria
(org.hibernate.Criteria
) using result transformer, but I'm stuck when it comes to using CriteriaQuery
, because I don't have a list of answers to give to the join.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…