Skip to content

Commit

Permalink
Fix event publication test for spring boot 3.4
Browse files Browse the repository at this point in the history
It is not supported to *set* the id of an entity before saving.
This results in an optimistic locking failure.

Because hibernate assumes that an object with an ID was already loaded
from a database, it throws `StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)`
  • Loading branch information
vierbergenlars committed Nov 25, 2024
1 parent 7d21fc5 commit 608ac24
Showing 1 changed file with 0 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ void cleanup() {
@Test
void entityCreate_emitsEvent() {
var toCreate = new Customer();
toCreate.setId(UUID.randomUUID());
toCreate.setVat("BE123");
var customer = customerRepository.save(toCreate);

Expand Down

0 comments on commit 608ac24

Please sign in to comment.