As a repository has no concept of deleting an aggregate (only adding &
loading) it's necessary to add some action in the domain object if
someone tries to load a deleted aggregate again.
How do you handle deleted Aggregates?
I added a simple boolean "deleted" field and then all methods check
for deletion before executing.
If you use EventSourcing, you can use the AggregateDeletedEvent as a marker interface. If the repository encounters such an event when loading an aggregate, it will throw an AggregateDeletedException (which extends AggregateNotFoundException). See chapter 4.1.1 in the documentation (http://www.axonframework.org/docs/1.0/domain-modeling.html)
For regular repositories, it’s is probably best to implement a delete method. Currently there is none on the GenericJpaRepository. It might be a good idea to add one there. Thinking about it, I might even add an interface for special “delete-aware” repositories.
Just apply an event which implements the AggregateDeletedEvent marker interface. If you do try to load the aggregate from the repository you will receive an AggregateDeletedException.