mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2748 - Fix setDisableLazyLoading(true) ... does not set fully loaded state [fully loaded bean scenario]
This commit is contained in:
1 parent
9252e72581
commit
48404fc85d
2 files changed
+44
No files matched your search
@@ -270,6 +270,9 @@ class SqlTreeLoadBean implements SqlTreeLoad {
|
|||||||
if (disableLazyLoad) {
|
if (disableLazyLoad) {
|
||||||
// bean does not have an Id or is SqlSelect based
|
// bean does not have an Id or is SqlSelect based
|
||||||
ebi.setDisableLazyLoad(true);
|
ebi.setDisableLazyLoad(true);
|
||||||
|
if (!partialObject) {
|
||||||
|
ebi.setFullyLoadedBean(true);
|
||||||
|
}
|
||||||
} else if (partialObject) {
|
} else if (partialObject) {
|
||||||
if (readId) {
|
if (readId) {
|
||||||
// register for lazy loading
|
// register for lazy loading
|
||||||
|
|||||||
@@ -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