mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2377 - Wrong order in batch save, fix transaction depth
The guts of this fix is in DefaultPersister.saveAssocOne() with the change to use the new transaction.depthDecrement() method. For our failing test cases this changes the depth from -1, 0 to be 0, 1. We can see the impact of this change in the batch ordering via the logging of: io.ebean.SUM - txn[1001] BatchControl flush ...
This commit is contained in:
1 parent
b38a21f8c4
commit
f51f2269fb
10 files changed
+134
-59
No files matched your search
@@ -7,10 +7,11 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.relates.*;
|
||||
|
||||
public class TransactionTest extends BaseTestCase {
|
||||
private Relation1 r1 = new Relation1("R1");
|
||||
private Relation2 r2 = new Relation2("R2");
|
||||
private Relation3 r3 = new Relation3("R3");
|
||||
class TransactionTest extends BaseTestCase {
|
||||
|
||||
private final Relation1 r1 = new Relation1("R1");
|
||||
private final Relation2 r2 = new Relation2("R2");
|
||||
private final Relation3 r3 = new Relation3("R3");
|
||||
|
||||
private Transaction txn;
|
||||
|
||||
@@ -27,14 +28,14 @@ public class TransactionTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSave1() {
|
||||
void testMultiSave1() {
|
||||
r2.setWithCascade(r3);
|
||||
r1.setWithCascade(r2);
|
||||
DB.save(r1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSave2() {
|
||||
void testMultiSave2() {
|
||||
r2.setWithCascade(r3);
|
||||
r1.setWithCascade(r2);
|
||||
DB.save(r3);
|
||||
@@ -42,7 +43,7 @@ public class TransactionTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSave3() {
|
||||
void testMultiSave3() {
|
||||
r2.setWithCascade(r3);
|
||||
r1.setWithCascade(r2);
|
||||
DB.save(r3);
|
||||
@@ -51,7 +52,7 @@ public class TransactionTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSave4() {
|
||||
void testMultiSave4() {
|
||||
r2.setNoCascade(r3);
|
||||
r1.setWithCascade(r2);
|
||||
DB.save(r3);
|
||||
@@ -60,11 +61,20 @@ public class TransactionTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiSave5() {
|
||||
void testMultiSave4_usingRelation4() {
|
||||
Relation4 r4 = new Relation4("foo");
|
||||
r2.setR4NoCascade(r4);
|
||||
r1.setWithCascade(r2);
|
||||
DB.save(r4);
|
||||
DB.save(r1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultiSave5() {
|
||||
r2.setNoCascade(r3);
|
||||
r1.setNoCascade(r2);
|
||||
DB.save(r3);
|
||||
DB.save(r2);
|
||||
DB.save(r1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package org.tests.model.basic.relates;
|
||||
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Relation entity
|
||||
*/
|
||||
@@ -23,6 +25,9 @@ public class Relation2 {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
private Relation4 r4NoCascade;
|
||||
|
||||
@ManyToOne
|
||||
private Relation3 noCascade;
|
||||
|
||||
@@ -60,5 +65,12 @@ public class Relation2 {
|
||||
public void setWithCascade(Relation3 withCascade) {
|
||||
this.withCascade = withCascade;
|
||||
}
|
||||
|
||||
|
||||
public Relation4 getR4NoCascade() {
|
||||
return r4NoCascade;
|
||||
}
|
||||
|
||||
public void setR4NoCascade(Relation4 r4NoCascade) {
|
||||
this.r4NoCascade = r4NoCascade;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.tests.model.basic.relates;
|
||||
|
||||
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Relation entity
|
||||
*/
|
||||
@Entity
|
||||
@ChangeLog
|
||||
public class Relation4 {
|
||||
|
||||
@Id
|
||||
private UUID id = UUID.randomUUID();
|
||||
|
||||
private String name;
|
||||
|
||||
public Relation4(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user