{"record":{"id":"aa445eff40e2150c","repo":"hibernate/hibernate-orm","slug":"could-not-determine-the-record-components-for","errorCode":null,"errorMessage":"Could not determine the record components for: \" + javaType.getName()","messagePattern":"Could not determine the record components for: \" \\+ javaType\\.getName\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java","lineNumber":858,"sourceCode":"\t\treturn null;\n\t}\n\n\t@Deprecated(forRemoval = true)\n\tpublic static boolean isRecord(Class<?> declaringClass) {\n\t\treturn declaringClass.isRecord();\n\t}\n\n\tpublic static Class<?>[] getRecordComponentTypes(Class<?> javaType) {\n\t\ttry {\n\t\t\tfinal var recordComponents = javaType.getRecordComponents();\n\t\t\tfinal var componentTypes = new Class[recordComponents.length];\n\t\t\tfor (int i = 0; i < recordComponents.length; i++ ) {\n\t\t\t\tcomponentTypes[i] = recordComponents[i].getType();\n\t\t\t}\n\t\t\treturn componentTypes;\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Could not determine the record components for: \" + javaType.getName(),\n\t\t\t\t\te\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic static String[] getRecordComponentNames(Class<?> javaType) {\n\t\ttry {\n\t\t\tfinal var recordComponents = javaType.getRecordComponents();\n\t\t\tfinal var componentNames = new String[recordComponents.length];\n\t\t\tfor (int i = 0; i < recordComponents.length; i++ ) {\n\t\t\t\tcomponentNames[i] = recordComponents[i].getName();\n\t\t\t}\n\t\t\treturn componentNames;\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Could not determine the record components for: \" + javaType.getName(),","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java#L840-L876","documentation":"ReflectHelper.getRecordComponentTypes(Class) reflects over a Java record to return its component types. Anything that fails inside is caught and rethrown as IllegalArgumentException with this message, so the real reason rides on getCause(). The most common cause is javaType.getRecordComponents() returning null because the class is not actually a record; a SecurityException denying reflective access is the other path.","triggerScenarios":"Passing a class that is not a java.lang.Record (plain class, enum, interface, abstract class) to getRecordComponentTypes — getRecordComponents() returns null, the subsequent array access throws NullPointerException, and the catch wraps it. Also triggered when a security manager or module boundary denies access to record components.","commonSituations":"An @Embeddable or composite id expected to be a record but declared as a regular class; Kotlin/Scala/Groovy classes mistaken for JVM records; stale compiled class on the classpath predating a record conversion; instrumentation tools stripping the record flag.","solutions":["Check the class with Class.isRecord(); if false, convert it to a real Java record or map it as a normal embeddable class.","Clean and rebuild so the record-compiled version of the class is the one actually on the runtime classpath.","Read getCause() to separate 'not a record' (NullPointerException) from access denial (SecurityException) and fix accordingly."],"exampleFix":"// before: plain class where record semantics are assumed\npublic class Money {\n    private final BigDecimal amount;\n    public Money(BigDecimal amount) { this.amount = amount; }\n    public BigDecimal amount() { return amount; }\n}\n\n// after\npublic record Money(BigDecimal amount) {}","handlingStrategy":"type-guard","validationCode":"static void requireRecord(Class<?> cls) {\n    if (cls == null || !cls.isRecord()) {\n        throw new IllegalArgumentException(\"Not a java record: \" + cls);\n    }\n}","typeGuard":"static boolean isRecord(Class<?> cls) {\n    return cls != null && cls.isRecord();\n}","tryCatchPattern":"try {\n    Class<?>[] types = ReflectHelper.getRecordComponentTypes(cls);\n} catch (IllegalArgumentException e) {\n    // e.getCause(): NullPointerException -> cls is not a record; SecurityException -> access denied\n}","preventionTips":["Verify Class.isRecord() before any record-specific reflection.","Keep a single compiled source of truth for record classes across modules.","Run on JDK 16+ when records participate in the mapping model."],"tags":["hibernate","reflection","java-records","mapping"],"backgroundTag":"record-component-reflection-failure","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}