I'm using CrudRepository.save(Entity)
to insert an Entity with @ID
already populated.
I'm getting the following exception.
Caused by: org.springframework.dao.IncorrectUpdateSemanticsDataAccessException: Failed to update entity [com.comanyname.repository.Entiy.class]. Id [ed384316-9c22-4b63-90fd-ec02fdac2b86] not found in database.
I can understand the issue as @ID
field is already populated,
AggregateChangeExecutor here is treating this action as DbAction.Update.
So, I wanted to know if there is any way I can use CrudRepository.save(Entity)
to insert a new entity with a predefined @ID
field as I've wanted to use @DomainEvent
hook on CrudRepository.save(Entity).
I kind of feel that this a bug in spring-data-jdbc
.
Just wanted an opinion/solution here.