java - Hibernate query for multiple associations -


i have 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 query articles type.id = somevalue using hibernate criteria. right can query until source class 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))); 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -