Fix issue with ResultSetMappig for classes
This commit is contained in:
parent
dd43a3923b
commit
72d06c164a
|
@ -8,7 +8,6 @@ package org.hibernate.procedure.internal;
|
|||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.metamodel.MappingMetamodel;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
@ -16,9 +15,8 @@ import org.hibernate.query.internal.ResultSetMappingResolutionContext;
|
|||
import org.hibernate.query.named.NamedObjectRepository;
|
||||
import org.hibernate.query.named.NamedResultSetMappingMemento;
|
||||
import org.hibernate.query.results.ResultSetMapping;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
|
@ -76,15 +74,9 @@ public class Util {
|
|||
Consumer<String> querySpaceConsumer,
|
||||
ResultSetMappingResolutionContext context) {
|
||||
final MappingMetamodel domainModel = context.getSessionFactory().getDomainModel();
|
||||
final TypeConfiguration typeConfiguration = domainModel.getTypeConfiguration();
|
||||
final JavaTypeDescriptorRegistry javaTypeDescriptorRegistry = domainModel.getTypeConfiguration().getJavaTypeDescriptorRegistry();
|
||||
|
||||
for ( Class<?> resultSetMappingClass : resultSetMappingClasses ) {
|
||||
final JavaTypeDescriptor<?> basicType = typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( resultSetMappingClass );
|
||||
if ( basicType != null ) {
|
||||
resultSetMapping.addResultBuilder( new ScalarDomainResultBuilder<>( basicType ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( resultSetMappingClass );
|
||||
if ( entityDescriptor != null ) {
|
||||
resultSetMapping.addResultBuilder( new EntityDomainResultBuilder( entityDescriptor ) );
|
||||
|
@ -92,6 +84,13 @@ public class Util {
|
|||
querySpaceConsumer.accept( querySpace );
|
||||
}
|
||||
}
|
||||
else {
|
||||
final JavaTypeDescriptor<?> basicType = javaTypeDescriptorRegistry.getDescriptor(
|
||||
resultSetMappingClass );
|
||||
if ( basicType != null ) {
|
||||
resultSetMapping.addResultBuilder( new ScalarDomainResultBuilder<>( basicType ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping
|
|||
import org.hibernate.query.EntityIdentifierNavigablePath;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.results.ResultsHelper;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||
import org.hibernate.sql.results.graph.AssemblerCreationState;
|
||||
import org.hibernate.sql.results.graph.DomainResult;
|
||||
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
||||
|
@ -56,6 +57,24 @@ public class EntityResultImpl implements EntityResult {
|
|||
this.resultAlias = resultAlias;
|
||||
this.lockMode = lockMode;
|
||||
|
||||
|
||||
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
|
||||
sqlAstCreationState.getFromClauseAccess().resolveTableGroup(
|
||||
navigablePath,
|
||||
np -> {
|
||||
return entityValuedModelPart.getEntityMappingType()
|
||||
.getEntityPersister()
|
||||
.createRootTableGroup(
|
||||
true,
|
||||
navigablePath,
|
||||
null,
|
||||
() -> p -> {},
|
||||
sqlAstCreationState,
|
||||
sqlAstCreationState.getCreationContext().getSessionFactory()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
this.discriminatorFetch = discriminatorFetchBuilder.apply( this );
|
||||
|
||||
this.fetches = creationState.visitFetches( this );
|
||||
|
|
|
@ -165,7 +165,7 @@ public class OutputsImpl implements Outputs {
|
|||
procedureCall.getParameterBindings().visitBindings(
|
||||
(parameterImplementor, queryParameterBinding) -> {
|
||||
ProcedureParameter parameter = (ProcedureParameter) parameterImplementor;
|
||||
if ( parameter.getMode() == ParameterMode.IN || parameter.getMode() == ParameterMode.INOUT ) {
|
||||
if ( parameter.getMode() == ParameterMode.INOUT ) {
|
||||
final JavaTypeDescriptor<?> basicType = javaTypeDescriptorRegistry.getDescriptor(
|
||||
parameterImplementor.getParameterType() );
|
||||
if ( basicType != null ) {
|
||||
|
|
Loading…
Reference in New Issue