rename findAll -> findMultiple, getAll -> getMultiple

This commit is contained in:
Gavin King 2024-10-18 21:22:22 +02:00
parent 86db807e22
commit 63d3d32f42
9 changed files with 23 additions and 23 deletions

View File

@ -697,8 +697,8 @@ public interface Session extends SharedSessionContract, EntityManager {
* matching a given identifier. If an instance is already associated with the session, that * matching a given identifier. If an instance is already associated with the session, that
* instance is returned. This method never returns an uninitialized instance. * instance is returned. This method never returns an uninitialized instance.
* <p> * <p>
* Every object returned by {@code findAll()} is either an unproxied instance of the given * Every object returned by {@code findMultiple()} is either an unproxied instance of the
* entity class, or a fully-fetched proxy object. * given entity class, or a fully-fetched proxy object.
* <p> * <p>
* For more advanced cases, use {@link #byMultipleIds(Class)}, which returns an instance of * For more advanced cases, use {@link #byMultipleIds(Class)}, which returns an instance of
* {@link MultiIdentifierLoadAccess}. * {@link MultiIdentifierLoadAccess}.
@ -711,7 +711,7 @@ public interface Session extends SharedSessionContract, EntityManager {
* @see #byMultipleIds(Class) * @see #byMultipleIds(Class)
* @since 7.0 * @since 7.0
*/ */
<E> List<E> findAll(Class<E> entityType, List<Object> ids, FindOption... options); <E> List<E> findMultiple(Class<E> entityType, List<Object> ids, FindOption... options);
/** /**
* Return the persistent instance of the given entity class with the given identifier, * Return the persistent instance of the given entity class with the given identifier,
@ -922,7 +922,7 @@ public interface Session extends SharedSessionContract, EntityManager {
* *
* @throws HibernateException If the given class does not resolve as a mapped entity * @throws HibernateException If the given class does not resolve as a mapped entity
* *
* @see #findAll(Class, List, FindOption...) * @see #findMultiple(Class, List, FindOption...)
*/ */
<T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass); <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass);

View File

@ -263,7 +263,7 @@ public interface StatelessSession extends SharedSessionContract {
* null elements representing missing entities * null elements representing missing entities
* @since 7.0 * @since 7.0
*/ */
<T> List<T> getAll(Class<T> entityClass, List<Object> ids); <T> List<T> getMultiple(Class<T> entityClass, List<Object> ids);
/** /**
* Refresh the entity instance state from the database. * Refresh the entity instance state from the database.

View File

@ -952,8 +952,8 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
} }
@Override @Override
public <E> List<E> findAll(Class<E> entityType, List<Object> ids, FindOption... options) { public <E> List<E> findMultiple(Class<E> entityType, List<Object> ids, FindOption... options) {
return delegate.findAll( entityType, ids, options ); return delegate.findMultiple( entityType, ids, options );
} }
@Override @Override

View File

@ -262,8 +262,8 @@ public class SessionLazyDelegator implements Session {
} }
@Override @Override
public <E> List<E> findAll(Class<E> entityType, List<Object> ids, FindOption... options) { public <E> List<E> findMultiple(Class<E> entityType, List<Object> ids, FindOption... options) {
return this.lazySession.get().findAll( entityType, ids, options ); return this.lazySession.get().findMultiple( entityType, ids, options );
} }
@Override @Override

View File

@ -988,7 +988,7 @@ public class SessionImpl
} }
@Override @Override
public <E> List<E> findAll(Class<E> entityType, List<Object> ids, FindOption... options) { public <E> List<E> findMultiple(Class<E> entityType, List<Object> ids, FindOption... options) {
return multiloadAccessWithOptions( entityType, options ).multiLoad( ids ); return multiloadAccessWithOptions( entityType, options ).multiLoad( ids );
} }

View File

@ -511,7 +511,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
} }
@Override @Override
public <T> List<T> getAll(Class<T> entityClass, List<Object> ids) { public <T> List<T> getMultiple(Class<T> entityClass, List<Object> ids) {
for (Object id : ids) { for (Object id : ids) {
if ( id == null ) { if ( id == null ) {
throw new IllegalArgumentException("Null id"); throw new IllegalArgumentException("Null id");

View File

@ -25,8 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@SessionFactory @SessionFactory
@DomainModel(annotatedClasses = {FindAllFetchProfileTest.Record.class, FindAllFetchProfileTest.Owner.class}) @DomainModel(annotatedClasses = {FindMultipleFetchProfileTest.Record.class, FindMultipleFetchProfileTest.Owner.class})
public class FindAllFetchProfileTest { public class FindMultipleFetchProfileTest {
@Test void test(SessionFactoryScope scope) { @Test void test(SessionFactoryScope scope) {
scope.inTransaction(s-> { scope.inTransaction(s-> {
Owner gavin = new Owner("gavin"); Owner gavin = new Owner("gavin");
@ -35,7 +35,7 @@ public class FindAllFetchProfileTest {
s.persist(new Record(456L,gavin,"hello mars")); s.persist(new Record(456L,gavin,"hello mars"));
}); });
scope.inTransaction(s-> { scope.inTransaction(s-> {
List<Record> all = s.findAll(Record.class, List.of(456L, 123L, 2L)); List<Record> all = s.findMultiple(Record.class, List.of(456L, 123L, 2L));
assertEquals("hello mars",all.get(0).message); assertEquals("hello mars",all.get(0).message);
assertEquals("hello earth",all.get(1).message); assertEquals("hello earth",all.get(1).message);
assertNull(all.get(2)); assertNull(all.get(2));
@ -43,7 +43,7 @@ public class FindAllFetchProfileTest {
assertFalse(Hibernate.isInitialized(all.get(1).owner)); assertFalse(Hibernate.isInitialized(all.get(1).owner));
}); });
scope.inTransaction(s-> { scope.inTransaction(s-> {
List<Record> all = s.findAll(Record.class, List.of(456L, 123L), List<Record> all = s.findMultiple(Record.class, List.of(456L, 123L),
new EnabledFetchProfile("withOwner")); new EnabledFetchProfile("withOwner"));
assertEquals("hello mars",all.get(0).message); assertEquals("hello mars",all.get(0).message);
assertEquals("hello earth",all.get(1).message); assertEquals("hello earth",all.get(1).message);

View File

@ -20,21 +20,21 @@ 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
@DomainModel(annotatedClasses = FindAllTest.Record.class) @DomainModel(annotatedClasses = FindMutipleTest.Record.class)
public class FindAllTest { public class FindMutipleTest {
@Test void test(SessionFactoryScope scope) { @Test void test(SessionFactoryScope scope) {
scope.inTransaction(s-> { scope.inTransaction(s-> {
s.persist(new Record(123L,"hello earth")); s.persist(new Record(123L,"hello earth"));
s.persist(new Record(456L,"hello mars")); s.persist(new Record(456L,"hello mars"));
}); });
scope.inTransaction(s-> { scope.inTransaction(s-> {
List<Record> all = s.findAll(Record.class, List.of(456L, 123L, 2L)); List<Record> all = s.findMultiple(Record.class, List.of(456L, 123L, 2L));
assertEquals("hello mars",all.get(0).message); assertEquals("hello mars",all.get(0).message);
assertEquals("hello earth",all.get(1).message); assertEquals("hello earth",all.get(1).message);
assertNull(all.get(2)); assertNull(all.get(2));
}); });
scope.inTransaction(s-> { scope.inTransaction(s-> {
List<Record> all = s.findAll(Record.class, List.of(456L, 123L), READ_ONLY); List<Record> all = s.findMultiple(Record.class, List.of(456L, 123L), READ_ONLY);
assertEquals("hello mars",all.get(0).message); assertEquals("hello mars",all.get(0).message);
assertEquals("hello earth",all.get(1).message); assertEquals("hello earth",all.get(1).message);
assertTrue(s.isReadOnly(all.get(0))); assertTrue(s.isReadOnly(all.get(0)));
@ -42,7 +42,7 @@ public class FindAllTest {
}); });
scope.inTransaction(s-> { scope.inTransaction(s-> {
Record record = s.getReference(Record.class, 456L); Record record = s.getReference(Record.class, 456L);
List<Record> all = s.findAll(Record.class, List.of(456L, 123L)); List<Record> all = s.findMultiple(Record.class, List.of(456L, 123L));
assertSame(record, all.get(0)); assertSame(record, all.get(0));
}); });
} }

View File

@ -17,15 +17,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
@SessionFactory @SessionFactory
@DomainModel(annotatedClasses = GetAllTest.Record.class) @DomainModel(annotatedClasses = GetMultipleTest.Record.class)
public class GetAllTest { public class GetMultipleTest {
@Test void test(SessionFactoryScope scope) { @Test void test(SessionFactoryScope scope) {
scope.inStatelessTransaction(s-> { scope.inStatelessTransaction(s-> {
s.insert(new Record(123L,"hello earth")); s.insert(new Record(123L,"hello earth"));
s.insert(new Record(456L,"hello mars")); s.insert(new Record(456L,"hello mars"));
}); });
scope.inStatelessTransaction(s-> { scope.inStatelessTransaction(s-> {
List<Record> all = s.getAll(Record.class, List.of(456L, 123L, 2L)); List<Record> all = s.getMultiple(Record.class, List.of(456L, 123L, 2L));
assertEquals("hello mars",all.get(0).message); assertEquals("hello mars",all.get(0).message);
assertEquals("hello earth",all.get(1).message); assertEquals("hello earth",all.get(1).message);
assertNull(all.get(2)); assertNull(all.get(2));