{"record":{"id":"efd78a7b49de2638","repo":"hibernate/hibernate-orm","slug":"unable-to-determine-javatype-to-use","errorCode":null,"errorMessage":"Unable to determine JavaType to use : {}","messagePattern":"Unable to determine JavaType to use : (.+?)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java","lineNumber":658,"sourceCode":"\t\t}\n\t}\n\n\tprivate Resolution<?> resolution(BasicJavaType explicitJavaType, JavaType<?> javaType) {\n\t\tfinal JavaType<?> basicJavaType;\n\t\tfinal JdbcType jdbcType;\n\t\tif ( explicitJdbcTypeAccess != null ) {\n\t\t\tfinal var typeConfiguration = getTypeConfiguration();\n\t\t\tjdbcType = explicitJdbcTypeAccess.apply( typeConfiguration );\n\t\t\tbasicJavaType = javaType == null && jdbcType != null\n\t\t\t\t\t? jdbcType.getRecommendedJavaType( null, null, typeConfiguration )\n\t\t\t\t\t: javaType;\n\t\t}\n\t\telse {\n\t\t\tjdbcType = null;\n\t\t\tbasicJavaType = javaType;\n\t\t}\n\t\tif ( basicJavaType == null ) {\n\t\t\tthrow new MappingException( \"Unable to determine JavaType to use : \" + this );\n\t\t}\n\n\t\tif ( basicJavaType instanceof BasicJavaType<?> castType\n\t\t\t\t&& ( !basicJavaType.getJavaTypeClass().isEnum() || enumerationStyle == null ) ) {\n\t\t\tfinal var context = getBuildingContext();\n\t\t\tfinal var autoAppliedTypeDef = context.getTypeDefinitionRegistry().resolveAutoApplied( castType );\n\t\t\tif ( autoAppliedTypeDef != null ) {\n\t\t\t\tCORE_LOGGER.trace( \"BasicValue resolution matched auto-applied type definition\" );\n\t\t\t\treturn autoAppliedTypeDef.resolve( getTypeParameters(), context, this );\n\t\t\t}\n\t\t}\n\n\t\treturn InferredBasicValueResolver.from(\n\t\t\t\texplicitJavaType,\n\t\t\t\tjdbcType,\n\t\t\t\tresolvedJavaType,\n\t\t\t\tthis::determineReflectedJavaType,\n\t\t\t\texplicitMutabilityPlanAccess,","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java#L640-L676","documentation":"During bootstrap, BasicValue resolution needs a domain JavaType: either one configured explicitly, or the recommended Java type of the explicitly assigned JdbcType when only @JdbcType/@JdbcTypeCode is present. When both routes yield null, Hibernate cannot build the type and throws this MappingException; the message includes the BasicValue dump identifying the attribute.","triggerScenarios":"@JdbcTypeCode(SqlTypes.JSON) on a field whose Java type has no registered JavaTypeDescriptor (custom value class without @JavaTypeRegistration); a custom UserType whose returnedClass() returns null; attributes typed Object or erased generics; Serializable-typed fields unresolved after a 5.x-to-6.x migration.","commonSituations":"Hibernate 6 migration where legacy type definitions no longer resolve; new custom value objects used with @JdbcTypeCode; fields declared with interface types; missing JavaType registrations for wrapper classes.","solutions":["Add @JavaType on the attribute or register a JavaType for the value class via @JavaTypeRegistration.","If a custom UserType is involved, make returnedClass() return the concrete class.","Give the attribute a concrete declared type instead of Object or a type variable."],"exampleFix":"// before\n@JdbcTypeCode(SqlTypes.JSON)\nprivate MyJsonDoc doc; // no JavaType registered for MyJsonDoc\n\n// after\n@JavaType(MyJsonDocJavaType.class)\n@JdbcTypeCode(SqlTypes.JSON)\nprivate MyJsonDoc doc;","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    SessionFactory sf = configuration.buildSessionFactory();\n}\ncatch ( MappingException e ) {\n    // message: Unable to determine JavaType to use : <BasicValue dump>\n    // use the dump to find the offending attribute, then add @JavaType/@Type\n}","preventionTips":["Register @JavaTypeRegistration for every custom value class up front","Unit-test SessionFactory creation for every module that carries mappings","Avoid Object-typed attributes; declare concrete types"],"tags":["hibernate","java-type","type-resolution","mapping"],"backgroundTag":"missing-type-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}