Remove an aggregate from the repository

631 views
Skip to first unread message

Marcus Linke

unread,
Jul 10, 2013, 5:02:39 AM7/10/13
to axonfr...@googlegroups.com
Hi,

while playing around with axon i wonder why it is not possible to remove an aggregate from the repository again. I suspect this has a conceptual reason but could somebody explain it shortly please?

Thanks

Marcus

Allard Buijze

unread,
Jul 10, 2013, 5:45:59 AM7/10/13
to Axon Framework Users
Hi Marcus,

deleting is actually possible. I assume you are using a object-relationally mapped aggregate? Deleting is considered a state change like any other. The only difference is that this state change sets the "deleted" flag on an aggregate. When the GenericJpaRepository detects this flag (AggregateRoot.isDeleted() returns true), it will delete it from the repository. If you extend one of Axon's abstract AggregateRoot classes, you can use "markDeleted()" to mark an aggregate as deleted.

EventSourcing repositories will not delete anything, they just append the events to the event store. When reading an aggregate back in, they will notice the "isDeleted" flag and throw an exception as if the aggregate doesn't exist.

Hope this helps.
Cheers,

Allard




Marcus

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Marcus Linke

unread,
Jul 10, 2013, 9:32:56 AM7/10/13
to axonfr...@googlegroups.com
Hi Allard,

thanks for this detailed explanation.

Regards
Reply all
Reply to author
Forward
0 new messages