|
21 | 21 | import java.util.StringTokenizer; |
22 | 22 | import java.util.function.Function; |
23 | 23 |
|
| 24 | +import org.hibernate.engine.spi.EntityEntry; |
24 | 25 | import org.hibernate.engine.spi.SessionFactoryImplementor; |
25 | 26 | import org.hibernate.engine.spi.SharedSessionContractImplementor; |
26 | 27 | import org.hibernate.internal.util.collections.CollectionHelper; |
@@ -662,28 +663,32 @@ private static void createValueBindings( |
662 | 663 | if ( parameterType == null ) { |
663 | 664 | throw new SqlTreeCreationException( "Unable to interpret mapping-model type for Query parameter : " + domainParam ); |
664 | 665 | } |
665 | | - else if ( parameterType instanceof PluralAttributeMapping ) { |
| 666 | + else if ( parameterType instanceof PluralAttributeMapping pluralAttributeMapping ) { |
666 | 667 | // Default to the collection element |
667 | | - parameterType = ( (PluralAttributeMapping) parameterType ).getElementDescriptor(); |
| 668 | + parameterType = pluralAttributeMapping.getElementDescriptor(); |
668 | 669 | } |
669 | 670 |
|
670 | | - if ( parameterType instanceof EntityIdentifierMapping ) { |
671 | | - final EntityIdentifierMapping identifierMapping = (EntityIdentifierMapping) parameterType; |
| 671 | + if ( parameterType instanceof EntityIdentifierMapping identifierMapping) { |
672 | 672 | final EntityMappingType entityMapping = identifierMapping.findContainingEntityMapping(); |
673 | 673 | if ( entityMapping.getRepresentationStrategy().getInstantiator().isInstance( bindValue, session.getFactory() ) ) { |
674 | 674 | bindValue = identifierMapping.getIdentifierIfNotUnsaved( bindValue, session ); |
675 | 675 | } |
676 | 676 | } |
677 | | - else if ( parameterType instanceof EntityMappingType ) { |
678 | | - final EntityIdentifierMapping identifierMapping = ( (EntityMappingType) parameterType ).getIdentifierMapping(); |
| 677 | + else if ( parameterType instanceof EntityMappingType entityMappingType ) { |
| 678 | + jdbcParameterBindings.addAffectedTableName( |
| 679 | + entityMappingType.getEntityPersister().getTableName() |
| 680 | + ); |
| 681 | + final EntityIdentifierMapping identifierMapping = entityMappingType.getIdentifierMapping(); |
679 | 682 | final EntityMappingType entityMapping = identifierMapping.findContainingEntityMapping(); |
680 | 683 | parameterType = identifierMapping; |
681 | 684 | if ( entityMapping.getRepresentationStrategy().getInstantiator().isInstance( bindValue, session.getFactory() ) ) { |
682 | 685 | bindValue = identifierMapping.getIdentifierIfNotUnsaved( bindValue, session ); |
683 | 686 | } |
684 | 687 | } |
685 | | - else if ( parameterType instanceof EntityAssociationMapping ) { |
686 | | - EntityAssociationMapping association = (EntityAssociationMapping) parameterType; |
| 688 | + else if ( parameterType instanceof EntityAssociationMapping association) { |
| 689 | + jdbcParameterBindings.addAffectedTableName( |
| 690 | + association.getAssociatedEntityMappingType().getEntityPersister().getTableName() |
| 691 | + ); |
687 | 692 | if ( association.getSideNature() == ForeignKeyDescriptor.Nature.TARGET ) { |
688 | 693 | // If the association is the target, we must use the identifier of the EntityMappingType |
689 | 694 | bindValue = association.getAssociatedEntityMappingType().getIdentifierMapping() |
|
0 commit comments