title: How to construct an insert query in JPA
body: <p>I am trying to insert data into a table having columns <strong>(NAME, VALUE)</strong> with </p>
  
  <pre><code>Query query = em.createQuery("INSERT INTO TestDataEntity (NAME, VALUE) VALUES (:name, :value)");
  query.setParameter("name", name);
  query.setParameter("value", value);
  query.executeUpdate();
  </code></pre>
  
  <p>and getting the following exception:</p>
  
  <pre><code>ERROR org.hibernate.hql.internal.ast.ErrorCounter - line 1:42: unexpected token: VALUES 
  </code></pre>
  
  <p>Also, I cannot insert a record using a native query either:</p>
  
  <pre><code>Query query = em.createNativeQuery("INSERT INTO TEST_DATA (NAME, VALUE) VALUES (:name, :value);");
  query.setParameter("name", name);
  query.setParameter("value", value);
  query.executeUpdate();
  </code></pre>
  
  <p>Another exception is being thrown:</p>
  
  <pre><code>javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
  </code></pre>
  
  <p><strong>The question is:</strong></p>
  
  <ul>
  <li>What is wrong with the query string?</li>
  </ul>
  
  <p>Many thanks.</p>