java - Hibernate error - QuerySyntaxException: administrator is not mapped error -


full error message:

11:49:51,896 info [stdout] (http-localhost-127.0.0.1-8080-1)  javax.ejb.ejbexception:  java.lang.illegalargumentexception: org.hibernate.hql.internal.ast.querysyntaxexception:      administrator not mapped [select ad administrator ad ad.adminid='123' , ad.password='123'] 
@stateless public class manageadministrator implements manageadministratorremote {     @persistencecontext(unitname = "jpadb")     private entitymanager entitymanager;          public manageadministrator() {     }      public administrator createadministrator(administrator adminid )     {         entitymanager.persist(adminid);         system.out.println("inside create administrator");         entitymanager.flush();         return adminid;     }      public list retrievealladministrators()     {         string q = "select ad " + administrator.class.getname() + " ad";         query query = entitymanager.createquery(q);         list administrators = (list) query.getresultlist();         return  administrators;     }      @override     public administrator adminlogin(administrator adminid) {         try {             string q ="select ad administrator ad ad.adminid='"                       + adminid.getadminid() +"'"                      + " , ad.password='"                      + adminid.getpassword() +"'";              query query = entitymanager.createquery(q);             query.setmaxresults(1);             //query.setparameter("loginemail", admin.getloginemail());             system.out.println(q);             return (administrator) query.getsingleresult();          }           catch(noresultexception e)           {                 return null;          }     }      @override     public int stringtoint(string word) {         // todo auto-generated method stub         return 0;     } 

may know cause of error ?

your entity class seems administrator (with capital @ start) while in query use administrator (with lower case @ start).jpa queries case-sensitive.

change line of code:

string q ="select ad administrator ad ad.adminid='" 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -