title: Hibernate nextval get id
body: <p>I use Hibernate with annotations. I need to insert object into the database using a method who needs one parameter that I need to calculate, to do this I use:</p>
  
  <pre><code>SQLQuery sqlQuery = getSession().createSQLQuery(queryString);
  sqlQuery.executeUpdate();
  </code></pre>
  
  <p>The queryString contains:</p>
  
  <pre><code>INSERT INTO TABLE(ID, NUMBER) VALUES (SEC_TABLE.NEXTVAL, 549)
  </code></pre>
  
  <p>The object is inserted into the database, but when I try to get the id, I get a null value.</p>
  
  <p>What can I do?</p>
  
  <p>When I use <code>getHibernateTemplate().update(obj);</code> I have not problems getting the id, but I need to customize the sql insert.</p>
  
  <p>Thanks</p>