title: nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
body: <p>This is the error I am getting. I have been stuck for 2 hours but could not resolve it.My code for hibernate is as follows:-</p>
  
  <pre><code>Session session1=new Configuration().configure("hibernate.cfg.xml").buildSessionFactory().openSession();
  
          org.hibernate.cfg.Configuration cfg=new org.hibernate.cfg.Configuration();
          cfg.configure("hibernate.cfg.xml");
          //creating seession factory object
          SessionFactory factory=cfg.buildSessionFactory();
  
          //creating session object
          Session session=factory.openSession();
  
          String hql = "SELECT E.id FROM User E where firstName=:name";
          SQLQuery query = session1.createSQLQuery(hql);
          query.setParameter("name", name);
          List results = query.list();
          Iterator itr=results.iterator();
          String id="";
          while(itr.hasNext()){ id=String.valueOf(itr.next());}
  
          //creating transaction object
          Transaction t=session.beginTransaction();
  
  
  
          User employee =
                  (User)session.get(User.class, 2);
          employee.setMessage(chat);
          session.update(employee);
  
  
          //template.save(e1);
  
          //session.persist(user);//persisting the object
  
          t.commit();//transaction is committed
          session.close();
          return "hello";
  </code></pre>
  
  <p>Any help would be appreciated..thanx in advance.</p>
  
  <p>My full stack trace is as follows:-</p>
  
  <pre><code>Stack Trace
  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:943)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
  io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
  io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
  io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
  org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
  io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
  io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
  io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
  io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63)
  io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
  io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
  io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
  io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
  io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)
  io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247)
  io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76)
  io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166)
  io.undertow.server.Connectors.executeRootHandler(Connectors.java:197)
  io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759)
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  java.lang.Thread.run(Thread.java:74
  </code></pre>
  
  <p>5)</p>