In a Spring Boot starter project I've created an AttributeConverter, and applied it with autoApply=true @Converter annotation. My problem is that the projects using the starter still need to specify @Convert for the fields.
I've created the AttributeConverter, and applied it with @Converter(autoApply = true):
@Converter(autoApply = true)
public class YearWeekDayAttributeConverter implements AttributeConverter<YearWeekDay, String> {
public String convertToDatabaseColumn(YearWeekDay yearWeekDay) {
return yearWeekDay.toString();
}
@Override
public YearWeekDay convertToEntityAttribute(String jsonString) {
return YearWeekDay.parse(jsonString);
}
}
Then I've added it to the auto configuration (org.springframework.boot.autoconfigure.AutoConfiguration.imports):
com.eg.nextgen.microservice.converters.YearWeekDayAttributeConverter
The problem comes when I use the starter in another project. I can specify @Convert for the entity fields, and it works perfectly. But if I don't specify @Convert the value is not converted - despite the fact that I added autoApply=true.
Any ideas as to why the autoApply doesn't work? If I put the converter in the project it is being used, and not in the starter project, it will also work (without specyfing @Convert).