#2110 Part2 - addBatch() does not auto flush (#2115)

This commit is contained in:
Rob Bygrave authored and GitHub committed 2020-11-25 22:18:05 +13:00
1 parent cc637d56e1
commit 8e91268979
4 files changed
+14 -16

No files matched your search

@@ -6,6 +6,7 @@ import io.ebean.SqlUpdate;
import io.ebean.Transaction;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
/**
@@ -27,9 +28,8 @@ public class TestSqlUpdateBatch extends BaseTestCase {
// Dummy updates, that effectively do nothing, but ebean doesn't need to know this.
final SqlUpdate update = DB.sqlUpdate("update uuone set name = ? where 0=1");
final SqlUpdate delete = DB.sqlUpdate("delete from uuone where ?=-1");
// txn.setBatchSize(40);
for (int i = 0; i <= 20; i++) {
for (int i = 0; i < 20; i++) {
update
.setParameter(1, String.valueOf(i))
.addBatch();
@@ -38,8 +38,8 @@ public class TestSqlUpdateBatch extends BaseTestCase {
.addBatch();
}
delete.executeBatch();
update.executeBatch();
assertThat(delete.executeBatch().length).isEqualTo(20);
assertThat(update.executeBatch().length).isEqualTo(20);
txn.commit();
}
}
@@ -52,7 +52,8 @@ public class TestSqlUpdateBatch extends BaseTestCase {
@Test
public void testBatchReturnArrayLength() {
try (Transaction txn = DB.beginTransaction()) {
txn.setBatchSize(100); // something bigger than 40
// transaction batch size is ignored with addBatch()
txn.setBatchSize(10);
// Dummy update, that effectively does nothing, but ebean doesn't need to know this.
final SqlUpdate update = DB.sqlUpdate("update uuone set name = ? where 0=1");
for (int i = 0; i < 40; i++) {