title: How to Insert into DB2 with NativeQuery and get generated ID
body: <p>I'm trying to insert a row into DB2 but i can figure out how to get the generated ID.</p>
  <p>With this code it's working but i can't get the ID:</p>
  <pre><code>    String sql = &quot;INSERT INTO MY_TABLE (MY_COLUMN) VALUES (?)&quot;;
      Query query = entityManager.createNativeQuery(sql);
      query.setParameter(1, &quot;MY_VALUE&quot;);
      query.executeUpdate();
  </code></pre>
  <p>I did some research, and tried to do like this:</p>
  <pre><code>    String sql = &quot;INSERT INTO MY_TABLE (MY_COLUMN) VALUES (?)&quot;;
      Query query = entityManager.createNativeQuery(sql);
      query.setParameter(1, &quot;MY_VALUE&quot;);
      BigDecimal id = (BigDecimal) query.getSingleResult(); 
  </code></pre>
  <p>But I got this error:</p>
  <pre><code>[org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-63) [jcc][t4][10103][10941][4.21.29] Method executeQuery cannot be used for update. ERRORCODE=-4476, SQLSTATE=null
  javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
  at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
  at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1535)
  at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1574)
  ...
  </code></pre>
  <p>What is the correct way to insert using NativeQuery and get the generated ID?</p>