Consider this use case : a mysql table X and a java JPA entiy X.
create table X
(id int(11),
name varchar(200),
value1 bigint(16),
value2 bigint(16),
value3 bigint(16),
.
.
value100 bigint(16));
I would like to map to an entity like this :
@Entity("x")
@Table("x")
public class X {
@Id
@Column("id)
public int getId ...
@Column("name")
public String getName ..
@SomeMagicalExpression
public List<Long> getValues()..
}
I am well aware of the option to create a join table where each value is a row, I am trying to get away from performing joins. I would really hate to create a 100 getters and setters.
Bit of a shot in the dark, but maybe the OpenJPA @Columns annotation will suit your needs..
Not sure if you could use it to map multiple columns to a collection though.. Maybe subclass ArrayList and override its constructor to take in a number of values to populate the list. (If my assumption that the values used in @Columns must correspond to a constructor is correct..)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.