title: Can't get Spring transaction to rollback (java+mysql)
body: <p>Last week I finally got around to making my app use transactions.  I am using Spring declarative transactions, and I know that the transactions themselves are working, as it made something with thousands of inserts go from 5-10 minutes to 5-10 seconds inside one transaction.   The database is MySQL and all the tables are InnoDB.   So I wanted to get this function to rollback if it doesn't work.  Basically, it is importing an xml file and building the database tables from the xml.  So if something fails, I don't want a partial upload or it will be inconsistent.  I have been exactly following the Spring documentation, and since I did get the transactions to run, I'm guessing the general configuration is right.  </p>
  
  <p>Here is the relevant part of the .xml file:</p>
  
  <pre><code>&lt;tx:advice id="txAdvice" transaction-manager="txManager"&gt;
    &lt;tx:attributes&gt;
      &lt;tx:method name="get*" read-only="true"/&gt;
      &lt;tx:method name="uploadModelToProject" rollback-for="Throwable"/&gt;
      &lt;tx:method name="*"/&gt;
    &lt;/tx:attributes&gt;
  &lt;/tx:advice&gt;
  </code></pre>
  
  <p>
    
    
    </p>
  
  <p>Here is the relevant part of the Service:</p>
  
  <pre><code>public interface ModelService {
      // interface to upload an LSI XML file of the  model into a project
      public Model uploadModelToProject(Project proj, String xmlFile);
  }
  </code></pre>
  
  <p>The uploadModelToProject calls a method in the SAX Parser implementation, which then implements the parsing</p>
  
  <pre><code>public Model importModelToProject(Project proj, String xmlInputFileName) throws SAXException, IOException, ParserConfigurationException, ImportException {
  
      //get a factory
      SAXParserFactory spf = SAXParserFactory.newInstance();
      try {
  
          //get a new instance of parser 
          SAXParser sp = spf.newSAXParser();          
  
          //parse the file and also register this object for callbacks
          sp.parse(xmlInputFileName, this);                               
  
      } finally {
          newModel = null;
      }
  
      return newModel;
  
  }
  </code></pre>
  
  <p>I have tried using rollback-for="Throwable", rollback-for="Exception", rollback-for="ImportException" (my own Exception).   Then I have manually thrown an exception in the code and it hasn't the worked.  I don't know if I need some propogation parameter or some other setting.  It doesn't seem like I am missing anything obvious.   Does anybody have any suggestions?  All that happens is an exception is thrown, and everything still goes into the database.   Am I missing an obvious step?</p>
  
  <p>Thanks for any help. </p>