@@ -5965,8 +5965,8 @@ else if ( binaryArithmetic.getRightHandOperand().getNodeType() == nodeType ) {
5965
5965
protected MappingModelExpressible <?> getInferredValueMapping () {
5966
5966
final MappingModelExpressible <?> inferredMapping = resolveInferredType ();
5967
5967
if ( inferredMapping != null ) {
5968
- if ( inferredMapping instanceof PluralAttributeMapping ) {
5969
- return ( ( PluralAttributeMapping ) inferredMapping ) .getElementDescriptor ();
5968
+ if ( inferredMapping instanceof PluralAttributeMapping pluralAttributeMapping ) {
5969
+ return pluralAttributeMapping .getElementDescriptor ();
5970
5970
}
5971
5971
else if ( !( inferredMapping instanceof JavaObjectType ) ) {
5972
5972
// Never report back the "object type" as inferred type and instead rely on the value type
@@ -6070,8 +6070,8 @@ else if ( paramType instanceof EntityDomainType ) {
6070
6070
// Try to infer the value mapping since the other side apparently is a path source
6071
6071
final MappingModelExpressible <?> inferredMapping = resolveInferredType ();
6072
6072
if ( inferredMapping != null ) {
6073
- if ( inferredMapping instanceof PluralAttributeMapping ) {
6074
- return resolveInferredValueMappingForParameter ( ( ( PluralAttributeMapping ) inferredMapping ) .getElementDescriptor () );
6073
+ if ( inferredMapping instanceof PluralAttributeMapping pluralAttributeMapping ) {
6074
+ return resolveInferredValueMappingForParameter ( pluralAttributeMapping .getElementDescriptor () );
6075
6075
}
6076
6076
else if ( !( inferredMapping instanceof JavaObjectType ) ) {
6077
6077
// Do not report back the "object type" as inferred type and instead try to rely on the paramSqmType.getExpressibleJavaType()
@@ -6263,23 +6263,8 @@ public Object visitTuple(SqmTuple<?> sqmTuple) {
6263
6263
final List <SqmExpression <?>> groupedExpressions = sqmTuple .getGroupedExpressions ();
6264
6264
final int size = groupedExpressions .size ();
6265
6265
final List <Expression > expressions = new ArrayList <>( size );
6266
- final MappingModelExpressible <?> mappingModelExpressible = resolveInferredType ();
6267
- final EmbeddableMappingType embeddableMappingType =
6268
- mappingModelExpressible instanceof ValueMapping valueMapping
6269
- ? (EmbeddableMappingType ) valueMapping .getMappedType ()
6270
- : null ;
6271
- if ( embeddableMappingType == null ) {
6272
- try {
6273
- inferrableTypeAccessStack .push ( () -> null );
6274
- for ( int i = 0 ; i < size ; i ++ ) {
6275
- expressions .add ( (Expression ) groupedExpressions .get ( i ).accept ( this ) );
6276
- }
6277
- }
6278
- finally {
6279
- inferrableTypeAccessStack .pop ();
6280
- }
6281
- }
6282
- else {
6266
+ if ( resolveInferredType () instanceof ValueMapping valueMapping
6267
+ && valueMapping .getMappedType () instanceof EmbeddableMappingType embeddableMappingType ) {
6283
6268
for ( int i = 0 ; i < size ; i ++ ) {
6284
6269
final AttributeMapping attributeMapping = embeddableMappingType .getAttributeMapping ( i );
6285
6270
inferrableTypeAccessStack .push ( () -> attributeMapping );
@@ -6291,17 +6276,31 @@ public Object visitTuple(SqmTuple<?> sqmTuple) {
6291
6276
}
6292
6277
}
6293
6278
}
6294
- final MappingModelExpressible <?> valueMapping ;
6295
- if ( mappingModelExpressible != null ) {
6296
- valueMapping = mappingModelExpressible ;
6279
+ else {
6280
+ try {
6281
+ inferrableTypeAccessStack .push ( () -> null );
6282
+ for ( int i = 0 ; i < size ; i ++ ) {
6283
+ expressions .add ( (Expression ) groupedExpressions .get ( i ).accept ( this ) );
6284
+ }
6285
+ }
6286
+ finally {
6287
+ inferrableTypeAccessStack .pop ();
6288
+ }
6289
+ }
6290
+ return new SqlTuple ( expressions , tupleValueMapping ( sqmTuple ) );
6291
+ }
6292
+
6293
+ private MappingModelExpressible <?> tupleValueMapping (SqmTuple <?> sqmTuple ) {
6294
+ final MappingModelExpressible <?> inferredType = resolveInferredType ();
6295
+ if ( inferredType != null ) {
6296
+ return inferredType ;
6297
+ }
6298
+ else if ( sqmTuple .getExpressible () instanceof MappingModelExpressible <?> modelExpressible ) {
6299
+ return modelExpressible ;
6297
6300
}
6298
6301
else {
6299
- valueMapping =
6300
- sqmTuple .getExpressible () instanceof MappingModelExpressible <?> modelExpressible
6301
- ? modelExpressible
6302
- : null ;
6302
+ return null ;
6303
6303
}
6304
- return new SqlTuple ( expressions , valueMapping );
6305
6304
}
6306
6305
6307
6306
@ Override
0 commit comments