diff --git a/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelX.java b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelX.java new file mode 100644 index 000000000..fbc3f9964 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelX.java @@ -0,0 +1,54 @@ +package org.tests.model.softdelete; + +import io.ebean.annotation.SoftDelete; + +import javax.persistence.*; +import java.util.UUID; + +@Entity +public class ESoftDelX { + + @Id + private UUID id; + + @OneToOne + private ESoftDelY y; + + @ManyToOne + private ESoftDelZ organization; + + @SoftDelete + boolean deleted; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public ESoftDelY getY() { + return y; + } + + public void setY(ESoftDelY y) { + this.y = y; + } + + public ESoftDelZ getOrganization() { + return organization; + } + + public void setOrganization(ESoftDelZ organization) { + this.organization = organization; + } + + public boolean isDeleted() { + return deleted; + } + + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } +} diff --git a/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelY.java b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelY.java new file mode 100644 index 000000000..a65cc75c1 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelY.java @@ -0,0 +1,53 @@ +package org.tests.model.softdelete; + +import io.ebean.annotation.SoftDelete; + +import javax.persistence.*; + +@Entity +public class ESoftDelY { + + @Id + private Long id; + + @ManyToOne + private ESoftDelZ organization; + + @OneToOne(mappedBy = "y") + private ESoftDelX x; + + @SoftDelete + boolean deleted; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public ESoftDelZ getOrganization() { + return organization; + } + + public void setOrganization(ESoftDelZ organization) { + this.organization = organization; + } + + public ESoftDelX getX() { + return x; + } + + public void setX(ESoftDelX x) { + this.x = x; + } + + public boolean isDeleted() { + return deleted; + } + + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } +} diff --git a/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelZ.java b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelZ.java new file mode 100644 index 000000000..5ce11c175 --- /dev/null +++ b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelZ.java @@ -0,0 +1,43 @@ +package org.tests.model.softdelete; + +import io.ebean.annotation.SoftDelete; + +import javax.persistence.Entity; +import javax.persistence.Id; +import java.util.UUID; + +@Entity +public class ESoftDelZ { + + @Id + private Long id; + + @SoftDelete + private boolean deleted; + + private UUID uuid; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public boolean isDeleted() { + return deleted; + } + + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + public UUID getUuid() { + return uuid; + } + + public void setUuid(UUID uuid) { + this.uuid = uuid; + } +} diff --git a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java index fc925f62c..2488060d4 100644 --- a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java +++ b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java @@ -1,9 +1,15 @@ package org.tests.softdelete; import io.ebean.BaseTestCase; +import io.ebean.DB; import io.ebean.Ebean; import org.tests.model.softdelete.ESoftDelMid; +import io.ebean.Finder; import org.junit.Test; +import org.tests.model.softdelete.ESoftDelY; +import org.tests.model.softdelete.ESoftDelZ; + +import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; @@ -24,5 +30,30 @@ public class TestSoftDeleteOptionalRelationship extends BaseTestCase { assertThat(bean.getTop()).isNull(); } + @Test + public void testFindNullWhenMultiple() { + UUID uuid = UUID.randomUUID(); + { + ESoftDelZ z = new ESoftDelZ(); + z.setUuid(uuid); + DB.save(z); + + ESoftDelY y = new ESoftDelY(); + y.setOrganization(z); + y.setX(null); + DB.save(y); + } + + Finder finder = new Finder<>(ESoftDelY.class); + ESoftDelY bean = finder + .query() + .where() + .eq("organization.uuid", uuid) + .isNull("x") + .findOne(); + + assertThat(bean).isNotNull(); + } + }