In 'clean architecture' the interactors (use cases) are responsible for defining busines logic. Most of the examples define use cases in such a way:
public MyUseCase() {
public boolean execute(...) {
int id = repository.insert(a)
if(id > 0) {
b.aId= id;
repository.insert(b);
...
}
}
}
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.
But what about use case inegrity. For instance, you can't be 100% sure that after inserting a
it will still be there when you insert b
.
What if after inserting a
you get some RepositoryException while inserting b
.
All the repos I've seen so far don't take it into account, so my question is:
What's the solution of the above problem in clean architecture?