From 09f616aae88e1b6646045537470df1d68ddcfdf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20P=C3=B6hler?= Date: Thu, 15 Jun 2023 12:03:49 +0200 Subject: [PATCH] ADD: testcase for showing an issue with deleting and re-adding many-to-many elements (size > 20) (cherry picked from commit e6a4bc4e0c31bb35ab5a13c958c7c4b1f68ca037) --- .../java/org/tests/m2m/TestM2MModifyTest.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ebean-test/src/test/java/org/tests/m2m/TestM2MModifyTest.java b/ebean-test/src/test/java/org/tests/m2m/TestM2MModifyTest.java index dc31662ab7..ed5a53a944 100644 --- a/ebean-test/src/test/java/org/tests/m2m/TestM2MModifyTest.java +++ b/ebean-test/src/test/java/org/tests/m2m/TestM2MModifyTest.java @@ -1,11 +1,12 @@ package org.tests.m2m; -import io.ebean.xtest.BaseTestCase; import io.ebean.DB; +import io.ebean.xtest.BaseTestCase; import org.junit.jupiter.api.Test; import org.tests.model.basic.MRole; import org.tests.model.basic.MUser; +import java.util.ArrayList; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -52,4 +53,27 @@ public void test() { roles = u0.getRoles(); assertThat(roles).hasSize(1); } + + @Test + public void test1() { + List roles = new ArrayList<>(); + for (int i = 0; i < 56; i++) { + MRole r0 = new MRole("mrole" + i); + roles.add(r0); + } + + DB.saveAll(roles); + + MUser u0 = new MUser("usr0"); + u0.getRoles().addAll(roles); + + DB.save(u0); + + u0 = DB.find(MUser.class, u0.getUserid()); + + u0.getRoles().clear(); + u0.getRoles().addAll(roles); + + DB.save(u0); + } }