# Hibernate 4.3.9 and mapping enums

I am currently working on upgrading Hibernate for a project, from 3.x to 4.3.9, and I am running into some strange error. I have several enum values in entities, all mapped as@Enumerated(EnumType.STRING). In previous versions of Hibernate this would be mapped asVARCHAR(255). But now, using MySQL, Hibernate tries to map it as atinyblob, which makes the validation fail.

From what I can tell from theMySQLDialect, the only way Hibernate can believe this to be atinyblobis if the type is mapped toTypes.VARBINARY. But I can't really see a reason for it to be mapped as anything other than aVARCHAR.

When looking at a previous version ofHibernate,4.1.1, I can see the following code inSimpleValueBinder:

if ( enumType != null ) {
if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) {
typeParameters.setProperty( EnumType.TYPE, String.valueOf( Types.INTEGER ) );
}
else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) {
typeParameters.setProperty( EnumType.TYPE, String.valueOf( Types.VARCHAR ) );
}
else {
throw new AssertionFailure( "Unknown EnumType: " + enumType );
}

This makes sense, and will make the type aVARCHAR. But, in the same class of4.3.9, this construct is missing. Also, it looks like the class has been refactored quite heavily.

Could this be a bug in version4.3.9ofHibernate?

Update: Strangely, I get exactly the same error with Hibernate4.3.10andMSSQL.

I got around this by introducing my own Hiberante-dialect, containing the following line:

registerColumnType(Types.VARBINARY, 255, "varchar(255)");

More of a workaround than a fix, though..