mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
#2581 - SoftDelete on @OneToMany is ignored after refresh() (since 12.11.5)
This commit is contained in:
1 parent
0d3649853a
commit
febd56c9c0
4 files changed
+85
-3
No files matched your search
@@ -7,14 +7,15 @@ import io.ebean.test.LoggedSql;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.EBasicClobNoVer;
|
||||
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestBasicClobNoVer extends BaseTestCase {
|
||||
class TestBasicClobNoVer extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
void test() {
|
||||
|
||||
EBasicClobNoVer entity = new EBasicClobNoVer();
|
||||
entity.setName("test");
|
||||
@@ -65,4 +66,21 @@ public class TestBasicClobNoVer extends BaseTestCase {
|
||||
assertThat(entity.getDescription()).isEqualTo("modified");
|
||||
}
|
||||
|
||||
@Test
|
||||
void refresh_withSoftDelete() {
|
||||
|
||||
EBasicClobNoVer bean = new EBasicClobNoVer();
|
||||
bean.setDescription("hello");
|
||||
DB.save(bean);
|
||||
|
||||
DB.refresh(bean);
|
||||
|
||||
LoggedSql.start();
|
||||
bean.children().forEach(System.out::println);
|
||||
List<String> sql = LoggedSql.stop();
|
||||
|
||||
assertThat(sql).hasSize(1);
|
||||
assertThat(sql.get(0)).contains(" and t0.deleted =");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package org.tests.model.basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class EBasicClobNoVer {
|
||||
@@ -18,6 +21,9 @@ public class EBasicClobNoVer {
|
||||
@Lob
|
||||
private String description;
|
||||
|
||||
@OneToMany
|
||||
private List<EBasicClobNoVerChild> children = new ArrayList<>();
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -41,4 +47,13 @@ public class EBasicClobNoVer {
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public List<EBasicClobNoVerChild> children() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public EBasicClobNoVer children(List<EBasicClobNoVerChild> children) {
|
||||
this.children = children;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.SoftDelete;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class EBasicClobNoVerChild {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private final EBasicClobNoVer parent;
|
||||
|
||||
private final String child;
|
||||
|
||||
@SoftDelete
|
||||
private boolean deleted;
|
||||
|
||||
public EBasicClobNoVerChild(EBasicClobNoVer parent, String child) {
|
||||
this.parent = parent;
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public Long id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public EBasicClobNoVerChild id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String child() {
|
||||
return child;
|
||||
}
|
||||
|
||||
public boolean deleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public EBasicClobNoVerChild deleted(boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user