{"record":{"id":"ba8b7dfb14acf082","repo":"hibernate/hibernate-orm","slug":"enumeratedvalue-for-enumtype-ordinal-must-be-plac","errorCode":null,"errorMessage":"@EnumeratedValue for EnumType.ORDINAL must be placed on a field whose type is byte, short, or int: %s.%s","messagePattern":"@EnumeratedValue for EnumType\\.ORDINAL must be placed on a field whose type is byte, short, or int: (.+?)\\.(.+?)","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java","lineNumber":496,"sourceCode":"\t\t\tif ( !String.class.equals( fieldType )\n\t\t\t\t\t&& !char.class.equals( fieldType ) ) {\n\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\"@EnumeratedValue for EnumType.STRING must be placed on a field whose type is String or char: %s.%s\",\n\t\t\t\t\t\t\t\tenumeratedValueField.getDeclaringClass().getName(),\n\t\t\t\t\t\t\t\tenumeratedValueField.getName()\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tassert stdIndicators.getEnumeratedType() == null || stdIndicators.getEnumeratedType() == EnumType.ORDINAL;\n\t\t\t// JPA says only byte, short, or int are valid here\n\t\t\tif ( !byte.class.equals( fieldType )\n\t\t\t\t\t&& !short.class.equals( fieldType )\n\t\t\t\t\t&& !int.class.equals( fieldType ) ) {\n\t\t\t\tthrow new MappingException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\"@EnumeratedValue for EnumType.ORDINAL must be placed on a field whose type is byte, short, or int: %s.%s\",\n\t\t\t\t\t\t\t\tenumeratedValueField.getDeclaringClass().getName(),\n\t\t\t\t\t\t\t\tenumeratedValueField.getName()\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static <T> BasicValue.Resolution<T> fromTemporal(\n\t\t\tTemporalJavaType<T> reflectedJtd,\n\t\t\tBasicJavaType<?> explicitJavaType,\n\t\t\tJdbcType explicitJdbcType,\n\t\t\tFunction<TypeConfiguration, MutabilityPlan<?>> explicitMutabilityPlanAccess,\n\t\t\tJdbcTypeIndicators stdIndicators) {\n","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java#L478-L514","documentation":"Error \"@EnumeratedValue for EnumType.ORDINAL must be placed on a field whose type is byte, short, or int: %s.%s\" 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":["Place @EnumeratedValue on a byte/short/int field of the enum, or switch the mapping to EnumType.STRING."],"exampleFix":"Place @EnumeratedValue on a byte/short/int field of the enum, or switch the mapping to EnumType.STRING.","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"}