HHH-17566 Fix named native query registration with entity result type

This commit is contained in:
Marco Belladelli 2023-12-14 16:09:48 +01:00 committed by Christian Beikov
parent 772af0de24
commit 0970550c63
1 changed files with 5 additions and 7 deletions

View File

@ -59,6 +59,7 @@ import org.hibernate.query.results.Builders;
import org.hibernate.query.results.ResultBuilder;
import org.hibernate.query.results.ResultSetMapping;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityCalculated;
import org.hibernate.query.results.dynamic.DynamicResultBuilderEntityStandard;
import org.hibernate.query.results.dynamic.DynamicResultBuilderInstantiation;
import org.hibernate.query.results.implicit.ImplicitModelPartResultBuilderEntity;
@ -475,13 +476,10 @@ public class NativeQueryImpl<R>
final List<ResultBuilder> resultBuilders = resultSetMapping.getResultBuilders();
if ( resultBuilders.size() == 1 ) {
final ResultBuilder resultBuilder = resultBuilders.get( 0 );
if ( resultBuilder instanceof ImplicitResultClassBuilder ) {
final ImplicitResultClassBuilder resultTypeBuilder = (ImplicitResultClassBuilder) resultBuilder;
return resultTypeBuilder.getJavaType();
}
else if ( resultBuilder instanceof ImplicitModelPartResultBuilderEntity ) {
final ImplicitModelPartResultBuilderEntity resultTypeBuilder = (ImplicitModelPartResultBuilderEntity) resultBuilder;
return resultTypeBuilder.getJavaType();
if ( resultBuilder instanceof ImplicitResultClassBuilder
|| resultBuilder instanceof ImplicitModelPartResultBuilderEntity
|| resultBuilder instanceof DynamicResultBuilderEntityCalculated ) {
return resultBuilder.getJavaType();
}
}
return null;