HHH-18409 byte[] instance variables annotated with @NaturalId cannot be found with a natural ID query

This commit is contained in:
Andrea Boriero 2024-09-20 11:14:56 +02:00 committed by Andrea Boriero
parent 71b3cb27d7
commit 5b25d09188
1 changed files with 9 additions and 2 deletions

View File

@ -5,7 +5,6 @@
package org.hibernate.metamodel.mapping.internal; package org.hibernate.metamodel.mapping.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
@ -246,7 +245,15 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement
@Override @Override
public boolean areEqual(Object one, Object other, SharedSessionContractImplementor session) { public boolean areEqual(Object one, Object other, SharedSessionContractImplementor session) {
return Arrays.equals( (Object[]) one, (Object[]) other ); final Object[] one1 = (Object[]) one;
final Object[] other1 = (Object[]) other;
final List<SingularAttributeMapping> naturalIdAttributes = getNaturalIdAttributes();
for ( int i = 0; i < naturalIdAttributes.size(); i++ ) {
if ( !naturalIdAttributes.get( i ).areEqual( one1[i], other1[i], session ) ) {
return false;
}
}
return true;
} }
@Override @Override