title: hibernate/spring is trying to insert rather than save (record already exists in db) after the previous transaction failed
body: <p>I have a batch interface class that creates a hibernate Session like this:</p>
  
  <pre><code>Session session = SessionFactoryUtils.getSession(sessionFactory, true);
  TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
  </code></pre>
  
  <p>Then it calls a service to get a list of objects from the DB, and in the batch class it iterates through that list and for each object it makes a service call to do some processing against the object. </p>
  
  <p>Say on the 2nd object some nullpointerexception occurs somewhere, and i catch the exception in my batch class. Then i try to process the 3rd object and in the service when it tries to save the object, by calling HibernateDaoSupport.getSession(false).save(object) - it actually tries to insert it (and i get an error because a record already exists) instead of updating it. </p>
  
  <p>This only happens if the previous object failed. If an exception occurs does it do something w/ that Hibernate session? Any ideas whats going on?</p>
  
  <p>I have the following in my app context.xml</p>
  
  <pre><code>    &lt;bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;tx:advice id="txAdvice" transaction-manager="txManager"&gt;
      &lt;tx:attributes&gt;
          &lt;tx:method name="*" rollback-for="Throwable"/&gt;
      &lt;/tx:attributes&gt;
  &lt;/tx:advice&gt;
  &lt;aop:config&gt;
      &lt;aop:pointcut id="serviceMethods" expression="execution(* com.company.service..*.*(..))" /&gt;
      &lt;aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" /&gt;
  &lt;/aop:config&gt;
  </code></pre>