{"record":{"id":"1be15e028defc79a","repo":"hibernate/hibernate-orm","slug":"could-not-determine-key-type-for-any-mapping-s","errorCode":null,"errorMessage":"Could not determine key type for '@Any' mapping (specify '@AnyKeyJavaType' or '@AnyKeyJavaClass')","messagePattern":"Could not determine key type for '@Any' mapping \\(specify '@AnyKeyJavaType' or '@AnyKeyJavaClass'\\)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java","lineNumber":886,"sourceCode":"\t\t\t\t\t\t\t\t.resolveDescriptor( anyKeyJavaClass.value() );\n\t\t\t}\n\n\t\t\t// mainly used in XML interpretation\n\t\t\tfinal var anyKeyType = member.locateAnnotationUsage( AnyKeyType.class, context );\n\t\t\tif ( anyKeyType != null ) {\n\t\t\t\tfinal String namedType = anyKeyType.value();\n\t\t\t\tfinal var registeredType =\n\t\t\t\t\t\ttypeConfiguration.getBasicTypeRegistry()\n\t\t\t\t\t\t\t\t.getRegisteredType( namedType );\n\t\t\t\tif ( registeredType == null ) {\n\t\t\t\t\tthrow new MappingException( \"Unrecognized @AnyKeyType value - \" + namedType );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn (BasicJavaType<?>) registeredType.getJavaTypeDescriptor();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new MappingException(\"Could not determine key type for '@Any' mapping (specify '@AnyKeyJavaType' or '@AnyKeyJavaClass')\");\n\t\t};\n\n\t\texplicitJdbcTypeAccess = typeConfiguration -> {\n\t\t\tfinal var anyKeyJdbcType = member.locateAnnotationUsage( AnyKeyJdbcType.class, context );\n\t\t\tif ( anyKeyJdbcType != null ) {\n\t\t\t\tfinal var jdbcTypeClass = anyKeyJdbcType.value();\n\t\t\t\tif ( jdbcTypeClass != null ) {\n\t\t\t\t\treturn useDeferredBeanContainerAccess\n\t\t\t\t\t\t\t? FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( jdbcTypeClass )\n\t\t\t\t\t\t\t: getManagedBeanRegistry().getBean( jdbcTypeClass ).getBeanInstance();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfinal var anyKeyJdbcTypeCode = member.locateAnnotationUsage( AnyKeyJdbcTypeCode.class, context );\n\t\t\tif ( anyKeyJdbcTypeCode != null ) {\n\t\t\t\tfinal int code = anyKeyJdbcTypeCode.value();\n\t\t\t\tif ( code != Integer.MIN_VALUE ) {\n\t\t\t\t\treturn getDescriptor( typeConfiguration, code );","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java#L868-L904","documentation":"Error \"Could not determine key type for '@Any' mapping (specify '@AnyKeyJavaType' or '@AnyKeyJavaClass')\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An @Any/@ManyToAny mapping is missing required key-type or join information.","commonSituations":"Polymorphic @Any associations without @AnyKeyJavaType/@AnyKeyJavaClass, without any @JoinColumn, or with an unrecognized @AnyKeyType value.","solutions":["Specify the key type explicitly with @AnyKeyJavaType or @AnyKeyJavaClass on the @Any mapping."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}