{"record":{"id":"f1b21b0dfb16e18e","repo":"hibernate/hibernate-orm","slug":"incorrect-use-of-entity-type-resolvedjavatype-ge","errorCode":null,"errorMessage":"Incorrect use of entity type '<resolvedJavaType.getTypeName()>' (possibly due to missing association mapping annotation)","messagePattern":"Incorrect use of entity type '<resolvedJavaType\\.getTypeName\\(\\)>' \\(possibly due to missing association mapping annotation\\)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java","lineNumber":271,"sourceCode":"\t\telse {\n\t\t\tlength = scale = null;\n\t\t}\n\t\treturn explicitJdbcType.getRecommendedJavaType( length, scale, typeConfiguration );\n\t}\n\n\tprivate static <T> JdbcType recommendedJdbcType(\n\t\t\tType resolvedJavaType,\n\t\t\tJdbcTypeIndicators stdIndicators,\n\t\t\tMetadataBuildingContext buildingContext,\n\t\t\tJavaType<T> reflectedJtd) {\n\t\ttry {\n\t\t\treturn reflectedJtd.getRecommendedJdbcType( stdIndicators );\n\t\t}\n\t\tcatch (JdbcTypeRecommendationException jtre) {\n\t\t\tif ( buildingContext.getMetadataCollector()\n\t\t\t\t\t.getEntityBindingMap().values().stream()\n\t\t\t\t\t.anyMatch( pc -> pc.getMappedClass().equals( resolvedJavaType ) ) ) {\n\t\t\t\tthrow new MappingException( \"Incorrect use of entity type '\" + resolvedJavaType.getTypeName()\n\t\t\t\t\t\t\t+ \"' (possibly due to missing association mapping annotation)\", jtre );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow jtre;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static <T> BasicType<T> registeredType(\n\t\t\tJdbcType explicitJdbcType,\n\t\t\tFunction<TypeConfiguration, MutabilityPlan<?>> explicitMutabilityPlanAccess,\n\t\t\tJdbcTypeIndicators stdIndicators,\n\t\t\tSelectable selectable,\n\t\t\tJavaType<T> reflectedJtd,\n\t\t\tBootstrapContext bootstrapContext,\n\t\t\tDialect dialect) {\n\t\tfinal var basicTypeRegistry =\n\t\t\t\tbootstrapContext.getTypeConfiguration().getBasicTypeRegistry();","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java#L253-L289","documentation":"Error \"Incorrect use of entity type '<resolvedJavaType.getTypeName()>' (possibly due to missing association mapping annotation)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An entity mapping annotation or bootstrap configuration violates a Hibernate mapping rule.","commonSituations":"Annotation mapping mistakes: inverse-side @Id associations, @Column on @OneToOne, unmapped association targets, mismatched @EnumeratedValue/@Temporal usage, duplicate sequence generators.","solutions":["Add the missing association annotation (@ManyToOne/@OneToOne/@ElementCollection etc.) on the property referencing the entity type."],"exampleFix":"Add the missing association annotation (@ManyToOne/@OneToOne/@ElementCollection etc.) on the property referencing the entity type.","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"}