Skip to content

Commit a93e0a7

Browse files
committed
HHH-18409 byte[] instance variables annotated with @naturalid cannot be found with a natural ID query
1 parent c7e17ae commit a93e0a7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package org.hibernate.metamodel.mapping.internal;
88

99
import java.util.ArrayList;
10-
import java.util.Arrays;
1110
import java.util.List;
1211
import java.util.Map;
1312
import java.util.function.BiConsumer;
@@ -248,7 +247,15 @@ public void verifyFlushState(Object id, Object[] currentState, Object[] loadedSt
248247

249248
@Override
250249
public boolean areEqual(Object one, Object other, SharedSessionContractImplementor session) {
251-
return Arrays.equals( (Object[]) one, (Object[]) other );
250+
final Object[] one1 = (Object[]) one;
251+
final Object[] other1 = (Object[]) other;
252+
final List<SingularAttributeMapping> naturalIdAttributes = getNaturalIdAttributes();
253+
for ( int i = 0; i < naturalIdAttributes.size(); i++ ) {
254+
if ( !naturalIdAttributes.get( i ).areEqual( one1[i], other1[i], session ) ) {
255+
return false;
256+
}
257+
}
258+
return true;
252259
}
253260

254261
@Override

0 commit comments

Comments
 (0)