Does micronaut-data support enum fields?
I tried creating enum field resulted in error. Added type converter using Micronaut TypeConverter
framework but still same error that it states
java.lang.NoSuchMethodError: 'void company.SyncRun.setStatus(java.lang.String)'
where SyncRun.status is enum field which has converter like below.
@Factory
class TypeConverters {
@Singleton
fun syncStatusToString(): TypeConverter<SyncStatus, String> {
return TypeConverter { value, targetType, context -> Optional.of(value.name) }
}
@Singleton
fun stringToSyncStatus(): TypeConverter<String, SyncStatus> {
return TypeConverter { value, targetType, context -> Optional.of(SyncStatus.valueOf(value)) }
}
}
With JPA you should simply annotate the enum property with @Enumerated(EnumType.STRING)
.
With JDBC it is working out of the box.