HHH-16821 Fail to delete entity with a composite id using an @IdClass with one of its fields mapped from the id of a @ManyToOne association

This commit is contained in:
Andrea Boriero 2023-06-23 12:04:44 +02:00 committed by Andrea Boriero
parent 44439cad95
commit 2e4211e8eb
2 changed files with 26 additions and 22 deletions

View File

@ -635,31 +635,35 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
for ( int i = 0; i < size; i++ ) {
final AttributeMapping attributeMapping = attributeMappings.get( i );
final Object attributeValue = values[ i ];
span += attributeMapping.breakDownJdbcValues(
attributeValue,
offset + span,
x,
y,
valueConsumer,
session
);
if ( !attributeMapping.isPluralAttributeMapping() ) {
final Object attributeValue = values[i];
span += attributeMapping.breakDownJdbcValues(
attributeValue,
offset + span,
x,
y,
valueConsumer,
session
);
}
}
}
else {
for ( int i = 0; i < size; i++ ) {
final AttributeMapping attributeMapping = attributeMappings.get( i );
final Object attributeValue = domainValue == null
? null
: attributeMapping.getPropertyAccess().getGetter().get( domainValue );
span += attributeMapping.breakDownJdbcValues(
attributeValue,
offset + span,
x,
y,
valueConsumer,
session
);
if ( !attributeMapping.isPluralAttributeMapping() ) {
final Object attributeValue = domainValue == null
? null
: attributeMapping.getPropertyAccess().getGetter().get( domainValue );
span += attributeMapping.breakDownJdbcValues(
attributeValue,
offset + span,
x,
y,
valueConsumer,
session
);
}
}
}
return span;

View File

@ -165,7 +165,7 @@ public class DeleteCoordinator extends AbstractMutationCoordinator {
for ( int attributeIndex = 0; attributeIndex < versionability.length; attributeIndex++ ) {
final AttributeMapping attribute;
// only makes sense to lock on singular attributes which are not excluded from optimistic locking
if ( versionability[attributeIndex] && ( attribute = persister.getAttributeMapping( attributeIndex ) ) instanceof SingularAttributeMapping ) {
if ( versionability[attributeIndex] && !( attribute = persister.getAttributeMapping( attributeIndex ) ).isPluralAttributeMapping() ) {
final Object loadedValue = loadedState[attributeIndex];
if ( loadedValue != null ) {
final String mutationTableName = persister.getAttributeMutationTableName( attributeIndex );
@ -424,7 +424,7 @@ public class DeleteCoordinator extends AbstractMutationCoordinator {
for ( int attributeIndex = 0; attributeIndex < versionability.length; attributeIndex++ ) {
final AttributeMapping attribute;
// only makes sense to lock on singular attributes which are not excluded from optimistic locking
if ( versionability[attributeIndex] && ( attribute = persister.getAttributeMapping( attributeIndex ) ) instanceof SingularAttributeMapping ) {
if ( versionability[attributeIndex] && !( attribute = persister.getAttributeMapping( attributeIndex ) ).isPluralAttributeMapping() ) {
breakDownJdbcValues( mutationGroupBuilder, session, attribute, loadedState[attributeIndex] );
}
}