title: Spring transactions for checked exceptions
body: <p>I'm struggling with a method in a Spring Service component which should be transactional. The method calls two other methods defined in the same class, both of them persisting data using Spring repositories extending <code>JpaRepository</code> (and therefore may throw unchecked exceptions), but one method (<code>methodB</code>) is also doing some filesystem operations which may throw checked exceptions. What is the correct to make this method transactional? So far I have this: </p>
  
  <pre><code>    @Service
      public class MyServiceImpl implements MyService {
        @Transactional
        public void doStuff() {
          methodA();
          try {  
            methodB();
          } catch (Throwable t) {
            throw new RuntimeException();
          }
        }
  
        public void methodB() throws MyCheckedExcpetion() {
          // some stuff
        }
        public void methodA() {
          // some stuff
        }
      }
  </code></pre>
  
  <p>Is there a better way?</p>