mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2110 - Fix for executeBatch() on SqlUpdate + refactor
- Changes to generally not close BatchedPstmt on executeBatch() and instead closed on commit/rollback
This commit is contained in:
1 parent
ce60eac583
commit
247e96f5db
8 files changed
+133
-102
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package org.tests.cascade;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Transaction;
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
@@ -49,6 +50,12 @@ public class TestMultiCascadeBatch extends BaseTestCase {
|
||||
|
||||
final List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
final List<Site> list = DB.find(Site.class).where()
|
||||
.idIn(grandparent.getId(), parent.getId(), child.getId())
|
||||
.findList();
|
||||
|
||||
assertThat(list).hasSize(3);
|
||||
|
||||
assertThat(sql).hasSize(5);
|
||||
assertSql(sql.get(0)).contains("insert into site (id, name");
|
||||
assertSql(sql.get(1)).contains("insert into site (id, name");
|
||||
|
||||
@@ -27,6 +27,7 @@ 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++) {
|
||||
update
|
||||
@@ -39,6 +40,7 @@ public class TestSqlUpdateBatch extends BaseTestCase {
|
||||
|
||||
delete.executeBatch();
|
||||
update.executeBatch();
|
||||
txn.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +52,10 @@ public class TestSqlUpdateBatch extends BaseTestCase {
|
||||
@Test
|
||||
public void testBatchReturnArrayLength() {
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
txn.setBatchSize(100); // something bigger than 40
|
||||
// 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++) {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
update
|
||||
.setParameter(1, String.valueOf(i))
|
||||
.addBatch();
|
||||
|
||||
Reference in new issue
Block a user