java - Hibernate - org.hibernate.QueryException: could not resolve property: -


i have class docmovement :

    @entity     @table(name = "doc_mvmnt")     public class docmovement {                 @id         @generatedvalue         @column(name = "mvmnt_id")         private int mvmnt_id;          @manytoone         @joincolumn(name = "barcode")         public docmaster docmaster;     // other fields , getters setters     } 

the docmaster class :

@entity  @table(name="doc_master") public class docmaster {         @id     @notnull     @column(name = "barcode")     private string barcode;      @column(name = "doc_no")     private string docno ;      @column(name="doc_type")     private string doctype;      @column(name="status")     private string status; // other fields , getters setters } 

when trying run following code :

criteria criteria = session.createcriteria(docmovement.class,"documentmovement");         criteria.add(restrictions.eq("documentmovement.recipientdetail.empid", empid));         criteria.add(restrictions.eq("documentmovement.iscurrent", true));         criteria.add(restrictions.ne("documentmovement.docmaster.status",fmsconstants.closed_status));         criteria.add(restrictions.ne("documentmovement.docmaster.status",fmsconstants.disposed_status));         list<docmovement> documentsheld = (list<docmovement>) criteria.list(); 

then following exception :

 [org.hibernate.queryexception: not resolve property:  docmaster.status of: com.fms.persistence.docmovement] root cause  org.hibernate.queryexception: not resolve property:  docmaster.status of: com.fms.persistence.docmovement 

there other cases try make query using criteria shown above, query runs fine, unable understand doing wrong in case. have tried using eager fetch too, earlier not using alias, tried using alias too.

please me solve issue !!!

try adding alias :

criteria.createalias("documentmovement.docmaster", "docmaster") 

and later call

 criteria.add(restrictions.ne("docmaster.status",fmsconstants.closed_status)); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -