Skip to content

Commit 5b25d09

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

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
@@ -5,7 +5,6 @@
55
package org.hibernate.metamodel.mapping.internal;
66

77
import java.util.ArrayList;
8-
import java.util.Arrays;
98
import java.util.List;
109
import java.util.Map;
1110
import java.util.function.BiConsumer;
@@ -246,7 +245,15 @@ public void verifyFlushState(Object id, Object[] currentState, Object[] loadedSt
246245

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

252259
@Override

0 commit comments

Comments
 (0)