Skip to content

@Convert(converter = StringToListConverter.class) removes the column from generated SQL #2119

@almothafar

Description

@almothafar

I have nvarchar column that contains strings joined by a delimiter, as for example code1,code2,code3 but in the code, I deal with them as List<String> codes so I used @Convert to deal with conversation, the problem is I see that using this is making the column used to disappear from SQL code generated:

image

Steps to reproduce

Column

    @Column(name = "TestCodes", length = 300)
    @Convert(converter = StringToListConverter.class)
    private List<String> testCodes;

Converter

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

    @Override
    public String convertToDatabaseColumn(List<String> list) {
        return list != null ? String.join(",", list) : null;
    }

    @Override
    public List<String> convertToEntityAttribute(String joined) {
        return joined != null ? new ArrayList<>(Arrays.asList(joined.split(","))) : null;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions