liefke / org.fastnate

The Offline SQL Generator
Apache License 2.0
16 stars 11 forks source link

Support AttributeConverter #36

Closed ahofmeister closed 6 years ago

ahofmeister commented 6 years ago

Fastnate does not support the following attribute:

@Column(columnDefinition = "VARCHAR")
@Convert(converter = StringListConverter.class)
private List<String> strings = new ArrayList<>(); 

With StringListConverter like:

@Converter
public class StringListConverter implements AttributeConverter<List<String>, String> {

    public String convertToDatabaseColumn(final List<String> list) {
    return String.join(",", list);
    }

    public List<String> convertToEntityAttribute(final String joined) {
        return new ArrayList<>(Arrays.asList(joined.split(",")));
    }

} 
liefke commented 6 years ago

Fastnate supports now a converter defined at the property level (like in your example). It still doesn't supports global converters (as it doesn't scan all files). Maybe this is something for a later version.