Skip to content

Commit fe7d281

Browse files
committed
HHH-17201 Unexpected value type exception for unordered multi id Load with ordered return disable
1 parent 438db8f commit fe7d281

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

hibernate-core/src/main/java/org/hibernate/internal/MultiIdentifierLoadAccessImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.hibernate.internal;
88

9+
import java.util.Collections;
910
import java.util.List;
1011
import java.util.function.Supplier;
1112

@@ -15,6 +16,7 @@
1516
import org.hibernate.graph.GraphSemantic;
1617
import org.hibernate.graph.RootGraph;
1718
import org.hibernate.graph.spi.RootGraphImplementor;
19+
import org.hibernate.loader.ast.internal.LoaderHelper;
1820
import org.hibernate.persister.entity.EntityPersister;
1921
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
2022

@@ -165,6 +167,13 @@ public List<T> perform(Supplier<List<T>> executor) {
165167
@Override
166168
@SuppressWarnings( "unchecked" )
167169
public <K> List<T> multiLoad(List<K> ids) {
168-
return perform( () -> (List<T>) entityPersister.multiLoad( ids.toArray( new Object[ 0 ] ), session, this ) );
170+
if ( ids.isEmpty() ) {
171+
return Collections.emptyList();
172+
}
173+
return perform( () -> (List<T>) entityPersister.multiLoad(
174+
ids.toArray( LoaderHelper.createTypedArray( ids.get( 0 ).getClass(), ids.size() ) ),
175+
session,
176+
this
177+
) );
169178
}
170179
}

0 commit comments

Comments
 (0)