Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ichtil committed Jan 27, 2023
1 parent 5f6efd2 commit 743f1b1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ebean-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>13.6.6-SNAPSHOT</version>
<version>13.6.6</version>
</parent>

<name>ebean test</name>
Expand All @@ -29,20 +29,20 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>13.6.6-SNAPSHOT</version>
<version>13.6.5</version>
</dependency>

<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>13.6.6-SNAPSHOT</version>
<version>13.6.5</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>13.6.6-SNAPSHOT</version>
<version>13.6.5</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -106,7 +106,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-all</artifactId>
<version>13.6.6-SNAPSHOT</version>
<version>13.6.5</version>
<scope>test</scope>
</dependency>

Expand Down
40 changes: 40 additions & 0 deletions ebean-test/src/test/java/org/tests/o2m/StatefulO2MSoftDelete.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.tests.o2m;

import io.ebean.DB;
import io.ebean.test.LoggedSql;
import io.ebean.xtest.BaseTestCase;
import org.junit.jupiter.api.Test;
import org.tests.o2m.dm.GoodsEntity;
import org.tests.o2m.dm.WorkflowEntity;
import org.tests.o2m.dm.WorkflowOperationEntity;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

public class StatefulO2MSoftDelete extends BaseTestCase {
@Test
void statefulUpdateShouldntDelete() {
var bomGoods = new GoodsEntity();
DB.save(bomGoods);

var goods = new GoodsEntity();
var workflow = new WorkflowEntity();
var operation1 = new WorkflowOperationEntity();
operation1.setName("operation 1");
goods.setWorkflowEntity(workflow);
workflow.setOperations(List.of(operation1));

DB.save(goods);

LoggedSql.start();
// replace workflow entity
var goodsFromDB = DB.find(GoodsEntity.class, goods.getId());
goodsFromDB.setWorkflowEntity(new WorkflowEntity());

DB.update(goodsFromDB);
var updateSql = LoggedSql.stop();
updateSql.forEach(System.out::println);
updateSql.forEach(sql -> assertThat(sql).doesNotContain("delete from workflow_entity"));
}
}

0 comments on commit 743f1b1

Please sign in to comment.