title: Hibernate insert doesn't work with custom native query
body: <p>In a spring boot project and database SQL Server, I'm doing some inserts where I need to return the id of the record
  I have a Entity with few fields:</p>
  <pre><code>public class PackGroupEntity{
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long group_id;
      private String group;
      private String remark;
      private String description;
      ....
  }
  </code></pre>
  <p>I simplified the insert just to ask the question.</p>
  <p>I have an insert statement and I need to retrieve the id from the inserted record.</p>
  <pre><code>String query = String.format(
                  &quot;insert into pack_group(group, remark, description ) &quot; +
                  &quot;values ( %s, %s, %s)&quot;, &quot;a&quot;,&quot;b&quot;,&quot;c&quot;  );
  Query q = entityManager.createNativeQuery(query );
  BigInteger biid = (BigInteger) q.getSingleResult();
  long id = biid.longValue();
  </code></pre>
  <p>And I get this error
  <code>com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.</code></p>
  <p>Based on this answer <a href="https://stackoverflow.com/a/49976101/13769578">here</a> that I can use <code>returning id</code> so I tried but:</p>
  <pre><code>String query = String.format(
                  &quot;insert into pack_group(group, remark, description ) &quot; +
                  &quot;values ( %s, %s, %s ) returning group_id;&quot;, &quot;a&quot;,&quot;b&quot;,&quot;c&quot;  );
  Query q = entityManager.createNativeQuery(query );
  BigInteger biid = (BigInteger) q.getSingleResult();
  long id = biid.longValue();
  </code></pre>
  <p>but it throws an error</p>
  <blockquote>
  <p>com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'returning'.</p>
  </blockquote>
  <p>Can someone help me, please?</p>