title: Spring + @Transactional: can't rollback in case of error
body: <p>I am trying to implement the following: I need to add two different entities in same same transaction to database. 
  I have different DAO classes and Service classes for each entity.</p>
  
  <pre><code>public class InvoicesDAO  {
      @Autowired
      protected SessionFactory sessionFactory;
  
      public void save(Invoice object) {
          Session session = SessionFactoryUtils.getSession(sessionFactory, false);
  
          session.persist(object);
      }
  }
  
  public class RequestsDAO {
      @Autowired
      protected SessionFactory sessionFactory;
  
      public void save(Request object) {
          Session session = SessionFactoryUtils.getSession(sessionFactory, false);
  
          session.persist(object);
      }
  }
  
  public class InvoicesService {
      @Autowired
      private InvoicesDAO invoicesDAO;
  
      @Autowired
      private RequestsDAO requestsDAO;
  
      @Transactional
      public void add(Invoice object) throws HibernateException {
          invoicesDAO.save(object);
      }
  
      @Transactional
      public void updateAndGenerate(Invoice object1, Request object2) throws HibernateException {
          invoicesDAO.save(object1);
          requestsDAO.save(object2);
      }
  }
  </code></pre>
  
  <p>The config:</p>
  
  <pre><code>&lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
      &lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="location" value="classpath:/hibernate.properties" /&gt;
      &lt;/bean&gt;
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="${hibernate.connection.driver_class}" /&gt;
          &lt;property name="url" value="${hibernate.connection.url}" /&gt;
          &lt;property name="username" value="${hibernate.connection.username}" /&gt;
          &lt;property name="password" value="${hibernate.connection.password}" /&gt;
      &lt;/bean&gt;      
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="packagesToScan" value="com.ejl.butler.object.data" /&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;
                  &lt;prop key="hibernate.format_sql"&gt;${hibernate.format_sql}&lt;/prop&gt;
                  &lt;prop key="hibernate.cache.use_query_cache"&gt;${hibernate.cache.use_query_cache}&lt;/prop&gt;
                  &lt;prop key="hibernate.cache.region.factory_class"&gt;${hibernate.cache.region.factory_class}&lt;/prop&gt;
             &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
  &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.service" /&gt;
      &lt;bean id="invoicesDao" class="com.dao.InvoicesDAO" /&gt;
  &lt;bean id="requestsDao" class="com.dao.RequestsDAO" /&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>//***
  /**
       * Invoices access service
       */
      @Autowired
      private InvoicesService invoicesService;
  
          // objects creation
          invoicesService.updateAndGenerate(invoice, request);
  //***
  </code></pre>
  
  <p>So when I am trying to call updateAndGenerate method and pass there invalid values for object2 - it fails without rolling back the object1. How can I fix it? Thank you</p>