I have the following structure in JAVA.
public class Article {
private long id;
private Source source;
}
public class Source {
private long id;
private Type type;
}
public class Type {
private long id;
private String sourceType;
}
How do I query all articles with Type.id = somevalue using Hibernate Criteria. Right now I can only query until Source class like this
Criteria query = currentSession().createCriteria(Article.class)
.createAlias("source", "s")
.add(Restrictions.eq("s.id", Long.parseLong(typeId)));
Try this
Criteria query = currentSession().createCriteria(Article.class)
.createAlias("source", "s")
.createAlias("s.type","t")
.add(Restrictions.eq("t.id", Long.parseLong(typeId)));