hibernate/hibernate-orm · error · AnnotationException
Embeddable '<name>' has a discriminator of character type an
Error message
Embeddable '<name>' has a discriminator of character type and must specify its '@DiscriminatorValue'
What it means
Error "Embeddable '<name>' has a discriminator of character type and must specify its '@DiscriminatorValue'" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java:822
BasicType<?> discriminatorType,
Map<Object, String> discriminatorValues) {
return discriminatorValues.put(
discriminatorType.getJavaTypeDescriptor()
.fromString( discriminatorValue( annotatedClass, discriminatorType ) ),
annotatedClass.getName().intern()
);
}
private static String discriminatorValue(ClassDetails annotatedClass, BasicType<?> discriminatorType) {
final String explicitValue =
annotatedClass.hasDirectAnnotationUsage( DiscriminatorValue.class )
? annotatedClass.getDirectAnnotationUsage( DiscriminatorValue.class ).value()
: null;
if ( isBlank( explicitValue ) ) {
final String name = unqualify( annotatedClass.getName() );
return switch ( discriminatorType.getName() ) {
case "character" ->
throw new AnnotationException( "Embeddable '" + name
+ "' has a discriminator of character type and must specify its '@DiscriminatorValue'" );
case "integer" -> String.valueOf( name.hashCode() );
default -> name;
};
}
else {
return explicitValue;
}
}
private static boolean isValidSuperclass(ClassDetails superClass, boolean isIdClass) {
if ( superClass == null ) {
return false;
}
else if ( isMappedSuperclass( superClass ) ) {
return true;
}
else if ( isIdClass ) {View on GitHub (pinned to fad1729dce)
Solutions
- Specify @DiscriminatorValue explicitly on the embeddable with a character-type discriminator.
When it happens
Trigger: An @Embeddable / @Embedded / @ElementCollection mapping violates an embeddable mapping constraint.
Common situations: Embeddables with @Id members, inheritance, recursive composition, or properties split across multiple tables; or @Convert/@EmbeddedTable placed where unsupported.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/8df633a7cfe9f473.
Report an issue: GitHub.