I read "Java Persistence with Hibernate" and read nothing about mapping multiple columns of a table into a Collection in the same table.
A more elegant/generic solution than the getter tweaking is maybe using an entity listener, that does the work of collecting all integers. With the use of an own annotation and reflection this may be "cleaner" solution.
Code:
@Entity
@EntityListeners(CollectableListener.class)
public class LegacyTable {
@Collectable(id=0)
private Integer m1;
@Collectable(id=1)
private Integer m2;
@Transient
private List<Integer> mAll;
}
public class CollectableListener {
@PostLoad
public void collectIntegers(Object entity) {
// ... get field by annotation, setting the list on the entity
}
}