79324267

Date: 2025-01-02 15:50:02
Score: 1.5
Natty:
Report link

As mentioned in https://stackoverflow.com/a/55146310 OTHER type can be used instead of VARCHAR for enums.

For Spring Data JDBC it can be achieved with a custom converter.

@Configuration
public class CustomJdbcConfiguration extends AbstractJdbcConfiguration {

    @Override
    @Nonnull
    protected List<?> userConverters() {
        return List.of(new MyEnumConverter());
    }

    @WritingConverter
    public static class MyEnumConverter implements Converter<MyEnum, JdbcValue> {
        @Override
        public JdbcValue convert(@Nonnull MyEnum source) {
            return JdbcValue.of(source, JDBCType.OTHER);
        }
    }
}
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: kolqw1