rename findAll -> findMultiple, getAll -> getMultiple
This commit is contained in:
parent
86db807e22
commit
63d3d32f42
|
@ -697,8 +697,8 @@ public interface Session extends SharedSessionContract, EntityManager {
|
|||
* matching a given identifier. If an instance is already associated with the session, that
|
||||
* instance is returned. This method never returns an uninitialized instance.
|
||||
* <p>
|
||||
* Every object returned by {@code findAll()} is either an unproxied instance of the given
|
||||
* entity class, or a fully-fetched proxy object.
|
||||
* Every object returned by {@code findMultiple()} is either an unproxied instance of the
|
||||
* given entity class, or a fully-fetched proxy object.
|
||||
* <p>
|
||||
* For more advanced cases, use {@link #byMultipleIds(Class)}, which returns an instance of
|
||||
* {@link MultiIdentifierLoadAccess}.
|
||||
|
@ -711,7 +711,7 @@ public interface Session extends SharedSessionContract, EntityManager {
|
|||
* @see #byMultipleIds(Class)
|
||||
* @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,
|
||||
|
@ -922,7 +922,7 @@ public interface Session extends SharedSessionContract, EntityManager {
|
|||
*
|
||||
* @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);
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ public interface StatelessSession extends SharedSessionContract {
|
|||
* null elements representing missing entities
|
||||
* @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.
|
||||
|
|
|
@ -952,8 +952,8 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <E> List<E> findAll(Class<E> entityType, List<Object> ids, FindOption... options) {
|
||||
return delegate.findAll( entityType, ids, options );
|
||||
public <E> List<E> findMultiple(Class<E> entityType, List<Object> ids, FindOption... options) {
|
||||
return delegate.findMultiple( entityType, ids, options );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -262,8 +262,8 @@ public class SessionLazyDelegator implements Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <E> List<E> findAll(Class<E> entityType, List<Object> ids, FindOption... options) {
|
||||
return this.lazySession.get().findAll( entityType, ids, options );
|
||||
public <E> List<E> findMultiple(Class<E> entityType, List<Object> ids, FindOption... options) {
|
||||
return this.lazySession.get().findMultiple( entityType, ids, options );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -988,7 +988,7 @@ public class SessionImpl
|
|||
}
|
||||
|
||||
@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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
|||
}
|
||||
|
||||
@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) {
|
||||
if ( id == null ) {
|
||||
throw new IllegalArgumentException("Null id");
|
||||
|
|
|
@ -25,8 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SessionFactory
|
||||
@DomainModel(annotatedClasses = {FindAllFetchProfileTest.Record.class, FindAllFetchProfileTest.Owner.class})
|
||||
public class FindAllFetchProfileTest {
|
||||
@DomainModel(annotatedClasses = {FindMultipleFetchProfileTest.Record.class, FindMultipleFetchProfileTest.Owner.class})
|
||||
public class FindMultipleFetchProfileTest {
|
||||
@Test void test(SessionFactoryScope scope) {
|
||||
scope.inTransaction(s-> {
|
||||
Owner gavin = new Owner("gavin");
|
||||
|
@ -35,7 +35,7 @@ public class FindAllFetchProfileTest {
|
|||
s.persist(new Record(456L,gavin,"hello mars"));
|
||||
});
|
||||
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 earth",all.get(1).message);
|
||||
assertNull(all.get(2));
|
||||
|
@ -43,7 +43,7 @@ public class FindAllFetchProfileTest {
|
|||
assertFalse(Hibernate.isInitialized(all.get(1).owner));
|
||||
});
|
||||
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"));
|
||||
assertEquals("hello mars",all.get(0).message);
|
||||
assertEquals("hello earth",all.get(1).message);
|
|
@ -20,21 +20,21 @@ import static org.junit.jupiter.api.Assertions.assertSame;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SessionFactory
|
||||
@DomainModel(annotatedClasses = FindAllTest.Record.class)
|
||||
public class FindAllTest {
|
||||
@DomainModel(annotatedClasses = FindMutipleTest.Record.class)
|
||||
public class FindMutipleTest {
|
||||
@Test void test(SessionFactoryScope scope) {
|
||||
scope.inTransaction(s-> {
|
||||
s.persist(new Record(123L,"hello earth"));
|
||||
s.persist(new Record(456L,"hello mars"));
|
||||
});
|
||||
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 earth",all.get(1).message);
|
||||
assertNull(all.get(2));
|
||||
});
|
||||
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 earth",all.get(1).message);
|
||||
assertTrue(s.isReadOnly(all.get(0)));
|
||||
|
@ -42,7 +42,7 @@ public class FindAllTest {
|
|||
});
|
||||
scope.inTransaction(s-> {
|
||||
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));
|
||||
});
|
||||
}
|
|
@ -17,15 +17,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
@SessionFactory
|
||||
@DomainModel(annotatedClasses = GetAllTest.Record.class)
|
||||
public class GetAllTest {
|
||||
@DomainModel(annotatedClasses = GetMultipleTest.Record.class)
|
||||
public class GetMultipleTest {
|
||||
@Test void test(SessionFactoryScope scope) {
|
||||
scope.inStatelessTransaction(s-> {
|
||||
s.insert(new Record(123L,"hello earth"));
|
||||
s.insert(new Record(456L,"hello mars"));
|
||||
});
|
||||
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 earth",all.get(1).message);
|
||||
assertNull(all.get(2));
|
Loading…
Reference in New Issue