From 608ac2463eb02d1a66c5ec9766cdd45b4b2c30f6 Mon Sep 17 00:00:00 2001 From: Lars Vierbergen Date: Mon, 25 Nov 2024 15:35:28 +0100 Subject: [PATCH] Fix event publication test for spring boot 3.4 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)` --- .../events/ChangeEventPublicationIntegrationTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/contentgrid-spring-integration-events/src/test/java/com/contentgrid/spring/integration/events/ChangeEventPublicationIntegrationTest.java b/contentgrid-spring-integration-events/src/test/java/com/contentgrid/spring/integration/events/ChangeEventPublicationIntegrationTest.java index f156e9fe..aba87438 100644 --- a/contentgrid-spring-integration-events/src/test/java/com/contentgrid/spring/integration/events/ChangeEventPublicationIntegrationTest.java +++ b/contentgrid-spring-integration-events/src/test/java/com/contentgrid/spring/integration/events/ChangeEventPublicationIntegrationTest.java @@ -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);