Clean Architecture - how to address database transactions? : <p>In 'clean architecture' the interactors (use cases) are responsible for defining busines logic. Most of the examples define use cases in such a way:</p>

<pre><code>public MyUseCase() {

  public boolean execute(...) {
    int id = repository.insert(a)
    if(id &gt; 0) {
      b.aId= id;
      repository.insert(b);
      ...
    }
  }
}
</code></pre>

<p>Interactors use mostly simple CRUD like operations or queries on repository.
The above example is synchronous for the case of simplicity but you can find repos with the same approach using asynchronous solutions like callbacks or rxjava.</p>

<p>But what about use case inegrity. For instance, you can't be 100% sure that after inserting <code>a</code> it will still be there when you insert <code>b</code>. 
What if after inserting <code>a</code> you get some RepositoryException while inserting <code>b</code>.</p>

<p>All the repos I've seen so far don't take it into account, so my question is:</p>

<p>What's the solution of the above problem in clean architecture?</p>
