java - Path expected for join hibernate -
i have problem hibernate hql queries , simple inner join
string hql = "select new es.criteria.crc.model.queryobjects.namequery(pf.name) person p inner join phisicalperson pf pf.idpersona = p.idpersona";     return personservice.query(hql); my java file has following code:
public class namequery{     private string name;      public namequery(string name) {         super();         this.name= name;     }      public string getname() {         return name;     }      public void setname(string name) {         this.name= name;     } } i recieve following error in console:
   caused by: java.lang.illegalargumentexception: org.hibernate.hql.internal.ast.querysyntaxexception: path expected join! 
you need have association (@onetomany, @onetoone) between person , phisicalperson. having such association don't need where clause
select new es.criteria.crc.model.queryobjects.namequery(pf.name)      person p inner join p.pf in example pf property of person, associated phisicalperson.
class person {      @onetoone(mappedby = "person")     private phisicalperson pf;  }  class phisicalperson {      @onetoone(fetch = fetchtype.lazy)     @joincolumn(name = "fk_person")     private person person;  } 
Comments
Post a Comment