Skip to content

Commit

Permalink
HHH-16349 Correct entity valued path selectable expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel authored and dreab8 committed Apr 14, 2023
1 parent 7d94921 commit 1382929
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.update.Assignable;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.sql.results.graph.Fetchable;

public class EntityValuedPathInterpretation<T> extends AbstractSqmPathInterpretation<T> implements SqlTupleContainer,
Assignable {
Expand Down Expand Up @@ -296,11 +296,13 @@ public static <T> EntityValuedPathInterpretation<T> from(
final Expression sqlExpression;

if ( resultModelPart == null ) {
// Expand to all columns of the entity mapping type, as we already did for the selection
final EntityMappingType entityMappingType = mapping.getEntityMappingType();
final EntityIdentifierMapping identifierMapping = entityMappingType.getIdentifierMapping();
final EntityDiscriminatorMapping discriminatorMapping = entityMappingType.getDiscriminatorMapping();
final int numberOfFetchables = entityMappingType.getNumberOfFetchables();
final List<Expression> expressions = new ArrayList<>(
entityMappingType.getJdbcTypeCount() + identifierMapping.getJdbcTypeCount()
numberOfFetchables + identifierMapping.getJdbcTypeCount()
+ ( discriminatorMapping == null ? 0 : 1 )
);
final TableGroup parentTableGroup = tableGroup;
Expand All @@ -318,7 +320,12 @@ public static <T> EntityValuedPathInterpretation<T> from(
if ( discriminatorMapping != null ) {
discriminatorMapping.forEachSelectable( selectableConsumer );
}
entityMappingType.forEachSelectable( selectableConsumer );
for ( int i = 0; i < numberOfFetchables; i++ ) {
final Fetchable fetchable = entityMappingType.getFetchable( i );
if ( fetchable.isSelectable() ) {
fetchable.forEachSelectable( selectableConsumer );
}
}
sqlExpression = new SqlTuple( expressions, entityMappingType );
}
else {
Expand Down

0 comments on commit 1382929

Please sign in to comment.