title: how to update the table in java using hibernate without using hql and sql
body: <p>I have tried a lot to update my table using hql but i didn't find the solution , i have searched on internet too, I am new in java and hibernate please help me to find the solution.</p>
  
  <p>my code is written below.</p>
  
  <pre><code>session.getTransaction().begin();
  Query query = session.createQuery("update DocDetail set DocName = :docname" + 
      " where Id = :docId");
  query.setParameter("docname", "Jack");
  query.setParameter("docId", 3);
  int result = query.executeUpdate();
  session.getTransaction().commit();
  </code></pre>
  
  <p>but I got the following error. </p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" org.hibernate.QueryException: query must begin with SELECT or FROM: update [update clinic.entity.DocDetail set DocName = :studentName where Id = :studentId]
  at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:106)
  at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:131)
  at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:51)
  </code></pre>