For times when a collection-oriented style doesn’t work, you will need to employ a persistence-oriented, save-based Repository. This will be the case when your persistence mechanism doesn’t implicitly or explicitly detect and track object changes. This happens to be the case when using an in-memory Data Fabric (4), or by any other name a NoSQL key-value data store. Every time you create a new Aggregate instance or change a preexisting one, you will have to put it into the data store by using
save() or a save-like Repository method.
There is another consideration for choosing a persistence-oriented approach, even if you are using an object-relational mapper that supports a collection-oriented approach. What would ...