title: session closing while using HibernateTemplate
body: <p>Consider following code:</p>
  
  <pre><code>public class UserDAOImpl implements UserDAO {
  
   private HibernateTemplate hibernateTemplate;
   public void setSessionFactory(SessionFactory sessionFactory){
    this.hibernateTemplate = new HibernateTemplate(sessionFactory);
    }
  
   public void saveUser(User user) {
   hibernateTemplate.saveOrUpdate(user);
   }
  
   public void deleteUser(User user) {
   hibernateTemplate.delete(user);
   }
  
  }
  </code></pre>
  
  <p>One of the main task of <code>HibernateTemplate</code> is to open and close the session transparently.</p>
  
  <p>In above code there are two methods <code>saveUser()</code> and <code>deleteUser()</code>.I want to ask:</p>
  
  <p>1)Will <code>HibernateTemplate</code> create two separate sessions for these two methods and when the closing/flushing of session takes place in this case. </p>
  
  <p>2)Is it same like spring transactions, as in spring, transactions are <em>adviced</em> around method calls and opening, closing of session happens at method/transaction boundaries?</p>