#2265 - ArrayIndexOutOfBoundsException: Index -1 out of bounds with @IdClass and batch insert accessing id property

This commit is contained in:
rbygrave
2021-07-13 11:30:31 +12:00
parent f8e54be9a6
commit e82b8c80f0
3 changed files with 38 additions and 4 deletions
@@ -1,7 +1,9 @@
package org.tests.model.bridge;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.Transaction;
import org.ebeantest.LoggedSqlCollector;
import org.junit.Test;
@@ -39,6 +41,28 @@ public class TestIdClassScalar extends BaseTestCase {
}
@Test
public void insertBatch() {
UUID siteId = UUID.randomUUID();
UUID userId = UUID.randomUUID();
try (final Transaction transaction = DB.beginTransaction()) {
transaction.setBatchMode(true);
BSiteUserD access = new BSiteUserD(BAccessLevel.ONE, siteId, userId);
DB.save(access);
final UUID siteId1 = access.getSiteId(); // ArrayIndexOutOfBoundsException here
assertThat(siteId1).isNotNull();
assertThat(access.getUserId()).isEqualTo(userId);
transaction.commit();
}
DB.delete(BSiteUserD.class, new BEmbId(siteId, userId));
}
@Test
public void test() {