HHH-16942 Make to-one's getJdbcTypeCount consistent with getSelectable

Also, cleanup some duplicated code in UpdateCoordinatorStandard
This commit is contained in:
Marco Belladelli 2023-07-17 12:38:23 +02:00 committed by Steve Ebersole
parent 78cc85aa05
commit 2a773b06ce
2 changed files with 7 additions and 21 deletions

View File

@ -2270,7 +2270,10 @@ public class ToOneAttributeMapping
@Override @Override
public int getJdbcTypeCount() { public int getJdbcTypeCount() {
return foreignKeyDescriptor.getJdbcTypeCount(); if ( sideNature == ForeignKeyDescriptor.Nature.KEY ) {
return foreignKeyDescriptor.getJdbcTypeCount();
}
return 0;
} }
@Override @Override

View File

@ -1118,11 +1118,11 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
final EntityTableMapping tableMapping = (EntityTableMapping) builder.getMutatingTable().getTableMapping(); final EntityTableMapping tableMapping = (EntityTableMapping) builder.getMutatingTable().getTableMapping();
final TableUpdateBuilder<?> tableUpdateBuilder = (TableUpdateBuilder<?>) builder; final TableUpdateBuilder<?> tableUpdateBuilder = (TableUpdateBuilder<?>) builder;
applyKeyRestriction( rowId, rowIdMapping, tableUpdateBuilder, tableMapping ); applyKeyRestriction( rowId, rowIdMapping, tableUpdateBuilder, tableMapping );
applyPartictionKeyRestriction( tableUpdateBuilder ); applyPartitionKeyRestriction( tableUpdateBuilder );
} ); } );
} }
private void applyPartictionKeyRestriction(TableUpdateBuilder<?> tableUpdateBuilder) { private void applyPartitionKeyRestriction(TableUpdateBuilder<?> tableUpdateBuilder) {
final AbstractEntityPersister persister = entityPersister(); final AbstractEntityPersister persister = entityPersister();
if ( persister.hasPartitionedSelectionMapping() ) { if ( persister.hasPartitionedSelectionMapping() ) {
final AttributeMappingsList attributeMappings = persister.getAttributeMappings(); final AttributeMappingsList attributeMappings = persister.getAttributeMappings();
@ -1630,7 +1630,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
updateBuilder.addKeyRestrictionsLeniently( identifierTableMapping.getKeyMapping() ); updateBuilder.addKeyRestrictionsLeniently( identifierTableMapping.getKeyMapping() );
updateBuilder.addOptimisticLockRestriction( versionMapping ); updateBuilder.addOptimisticLockRestriction( versionMapping );
addPartitionRestriction( updateBuilder ); applyPartitionKeyRestriction( updateBuilder );
//noinspection resource //noinspection resource
final JdbcMutationOperation jdbcMutation = factory() final JdbcMutationOperation jdbcMutation = factory()
@ -1644,23 +1644,6 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
} }
} }
private void addPartitionRestriction(AbstractTableUpdateBuilder<JdbcMutationOperation> updateBuilder) {
final AbstractEntityPersister persister = entityPersister();
if ( persister.hasPartitionedSelectionMapping() ) {
final AttributeMappingsList attributeMappings = persister.getAttributeMappings();
for ( int m = 0; m < attributeMappings.size(); m++ ) {
final AttributeMapping attributeMapping = attributeMappings.get( m );
final int jdbcTypeCount = attributeMapping.getJdbcTypeCount();
for ( int i = 0; i < jdbcTypeCount; i++ ) {
final SelectableMapping selectableMapping = attributeMapping.getSelectable( i );
if ( selectableMapping.isPartitioned() ) {
updateBuilder.addKeyRestrictionLeniently( selectableMapping );
}
}
}
}
}
@FunctionalInterface @FunctionalInterface
protected interface InclusionChecker { protected interface InclusionChecker {
boolean include(int position, SingularAttributeMapping attribute); boolean include(int position, SingularAttributeMapping attribute);