I am current porting some legacy code over to using JPA and have run into an issue trying to simplify one of the tables into an entity.
I have a table of various readings taken throughout a 24hr period - every half-hour. It looks like:
Date |R1|R2|R3...R48
1/1/2012,1,5,1,3,3,4,5,5....etc
I'd like my entity bean to look something like:
@Entity
public class Reading {
@Id
String date;
@??
int[] values;
@???
int sumOfValues
}
Any suggestions how I could approach this? Is it even possible? Also - I only want to read these values, if that make it any easier. I'm using EclipseLink 2.4 with MongoDB
** UPDATE **
Almost have it - but need to maintain order somehow (I think the fields are mapped out of order) - or pass through a reference to the column name:
@Entity
@Customizer (RawDataCustomizer.class)
public class Reading {
private List<Integer> values...
public void setValue(Integer value)...
public static class RawDataCustomizer implements DescriptorCustomizer {
@Override
public void customize(ClassDescriptor descriptor) throws Exception {
//loses ordering?
for (int i=1; i<=48; i++)
descriptor.addDirectMapping("R"+i, "getValue", "setValue", "r"+i);
}