From 9166d73f36f929529405385d4f6d87e3c71f4044 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Tue, 8 Oct 2024 09:05:48 +0200 Subject: [PATCH] HHH-18704 optimize away equals() search for records + enums --- .../java/org/hibernate/internal/util/ReflectHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java index 235882028a..8d679830df 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java @@ -117,6 +117,9 @@ public final class ReflectHelper { * @return True if clazz defines an equals override. */ public static boolean overridesEquals(Class clazz) { + if ( clazz.isRecord() || clazz.isEnum() ) { + return true; + } Method equals; try { equals = extractEqualsMethod( clazz ); @@ -134,6 +137,9 @@ public final class ReflectHelper { * @return True if clazz defines an hashCode override. */ public static boolean overridesHashCode(Class clazz) { + if ( clazz.isRecord() || clazz.isEnum() ) { + return true; + } Method hashCode; try { hashCode = extractHashCodeMethod( clazz );