#2748 - Fix setDisableLazyLoading(true) ... does not set fully loaded state [fully loaded bean scenario]

This commit is contained in:
Rob Bygrave
2022-07-20 07:55:42 +12:00
parent 9252e72581
commit 48404fc85d
2 changed files with 44 additions and 0 deletions
@@ -0,0 +1,41 @@
package org.tests.o2m;
import io.ebean.CacheMode;
import io.ebean.DB;
import io.ebean.Transaction;
import org.junit.jupiter.api.Test;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
class TestOneToManyDuplicateInTxn {
@Test
void findTwice() {
OMVertex master = new OMVertex(UUID.randomUUID());
OMVertexOther child = new OMVertexOther("child");
master.getRelated().add(child);
DB.save(master);
try (Transaction txn = DB.beginTransaction()) {
OMVertex first = DB.find(OMVertex.class)
.setDisableLazyLoading(true)
.fetch("related")
.where().eq("id", master.getId())
.findOne();
assertThat(first.getRelated()).hasSize(1);
OMVertex second = DB.find(OMVertex.class)
//.setLoadBeanCache(true)
.setBeanCacheMode(CacheMode.PUT)
.setDisableLazyLoading(true)
.fetch("related")
.where().eq("id", master.getId())
.findOne();
assertThat(second.getRelated()).hasSize(1);
}
}
}