Reputation: 11221
I have the below code
ArrayList<String> city = 'Anniston';
Criteria crit = session.createCriteria(CandidateResumeInfo.class);
crit.add(Restrictions.eq("resumeSearchable", 1));
Now i want to add below criteria
crit.add(Restrictions.in("cities", city));
but the problem is that cities column is not in CandidateResumeInfo.class its in CandidateInfo Class.
Any idea how to add this criteria as well in the above one,how to add CandidateInfo class as well in the above criteria.
guess i need to do join or link these two tables but how ,and will there be any changes in the entity classes ?
thanks
Upvotes: 0
Views: 2943
Reputation: 24732
You didn't describe your associations but I assume it would be something like
class CandidateResumeInfo {
@OneToOne
CandidateInfo candidate;
}
In this case you would need something like
ses.createCriteria(CandidateResumeInfo.class)
.add(Restrictions.eq(...))
.addCriteria('candidate')
.add(Restrictions.in('cities',city);
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html
check section about associations.
Upvotes: 1