mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2748 - Fix setDisableLazyLoading(true) ... does not set fully loaded state [fully loaded bean scenario]
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user