Search code examples
jpaopenjpa

OpenJPA: Multiple columns to List or Array


I've got an legacy database with colums like that: value_1, value_2, value_3...

For a new project I want these columns to one list or an array

@Entity
public class Example {

   @????
   private List<String> values;
   or
   private String[];
}

How should i write the annotations make it work?

I tried it with an custom ValueHandler, but no success. I also can't find any example how to solve the problem or an good example for an custom ValueHandler


Solution

  • @Column(name = "value_1")
    private String value1;
    
    @Column(name = "value_2")
    private String value2;
    
    public List<String> getValues() {
        return Arrays.asList(value1, value2);
    }