HHH-18544 multiload() and findAll() should return existing proxies
This commit is contained in:
parent
47270d4157
commit
d82913d65f
|
@ -218,6 +218,9 @@ public class MultiIdEntityLoaderArrayParam<E> extends AbstractMultiIdEntityLoade
|
||||||
// the entity is locally deleted, and the options ask that we not return such entities...
|
// the entity is locally deleted, and the options ask that we not return such entities...
|
||||||
entity = null;
|
entity = null;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
entity = persistenceContext.proxyFor( entity );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.set( resultIndex, entity );
|
result.set( resultIndex, entity );
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,6 +188,9 @@ public class MultiIdEntityLoaderStandard<T> extends AbstractMultiIdEntityLoader<
|
||||||
// the entity is locally deleted, and the options ask that we not return such entities...
|
// the entity is locally deleted, and the options ask that we not return such entities...
|
||||||
entity = null;
|
entity = null;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
entity = persistenceContext.proxyFor( entity );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.set( position, entity );
|
result.set( position, entity );
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
import static org.hibernate.ReadOnlyMode.READ_ONLY;
|
import static org.hibernate.ReadOnlyMode.READ_ONLY;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
|
@ -35,6 +36,11 @@ public class FindAllTest {
|
||||||
assertTrue(s.isReadOnly(all.get(0)));
|
assertTrue(s.isReadOnly(all.get(0)));
|
||||||
assertTrue(s.isReadOnly(all.get(1)));
|
assertTrue(s.isReadOnly(all.get(1)));
|
||||||
});
|
});
|
||||||
|
scope.inTransaction(s-> {
|
||||||
|
Record record = s.getReference(Record.class, 456L);
|
||||||
|
List<Record> all = s.findAll(Record.class, List.of(456L, 123L));
|
||||||
|
assertSame(record, all.get(0));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@Entity
|
@Entity
|
||||||
static class Record {
|
static class Record {
|
||||||
|
|
|
@ -276,7 +276,7 @@ public class MultiLoadTest {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @FailureExpected(jiraKey = "HHH-18544")
|
@Test
|
||||||
public void testBasicMultiLoadWithManagedAndNoCheckingProxied(SessionFactoryScope scope) {
|
public void testBasicMultiLoadWithManagedAndNoCheckingProxied(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
|
@ -290,7 +290,7 @@ public class MultiLoadTest {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @FailureExpected(jiraKey = "HHH-18544")
|
@Test
|
||||||
public void testBasicMultiLoadWithManagedAndCheckingProxied(SessionFactoryScope scope) {
|
public void testBasicMultiLoadWithManagedAndCheckingProxied(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
|
|
Loading…
Reference in New Issue