title: hibernate - get id after save object
body: <p>Because of an purpose, I need to get an id of an object  right after an insertion. I can work around with this code:</p>
  
  <pre><code> session.save(Object o)   // insert to database
   findByPorperty( o.property ) // Return the inserted object along with the id
  </code></pre>
  
  <p>I think the above code is not sufficient because the session need to reopen to find the object. So:</p>
  
  <ol>
  <li>Is there a better way obtain the id?</li>
  <li>If there is, can I apply the same strategy to obtain a list of ids after inserting a bag of object?</li>
  </ol>