Skip to content

Commit

Permalink
HHH-16821 Fail to delete entity with a composite id using an @IdClass…
Browse files Browse the repository at this point in the history
… with one of its fields mapped from the id of a @manytoone association
  • Loading branch information
dreab8 committed Jun 26, 2023
1 parent 44439ca commit 2e4211e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,31 +635,35 @@ public <X, Y> int breakDownJdbcValues(

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private void applyAllOrDirtyLocking(
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 );
Expand Down Expand Up @@ -424,7 +424,7 @@ protected void applyNonVersionOptLocking(
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] );
}
}
Expand Down

0 comments on commit 2e4211e

Please sign in to comment.