How update a aggregate root when using the GenericJpaRepository on the write side

When using the GenericJpaRepository only the add method is exposed which causes a insert statement to be fired. So if I had made a change in the state of an aggregate such that i would expect a update statement to be fired by JPA, how can i achieve it ?

Answering my own question, the add method also performs updates depending on whether the id attribute is populated or not …

But i guess the add method does not express the intent correctly , any thoughts ?

Hi Sudarshan,

the update is triggered by the Unit of Work. In Axon 2, there is no need to explicitly update an aggregate. When command handling is finished, the changes will be persisted to the repository that loaded the aggregate.
The “add” method should only be used to add new (thus insert) aggregates.



Thank you very much. It works perfectly. So far i have found Axon to be very intuitive.