Hi, I am a new hibernate user, and am tasked with adding spring and hibernate to some existing data. I am really not sure how to about it. The table data is structured similarly to the following:
Code:
DATE(PK) TYPE(PK) VALUE
01.01.2012 A hello
01.01.2012 B world
02.01.2012 A hi
02.01.2012 B there
Giving 2 objects as follows:
Object 1: {DATE=01.01.2012; A="hello";B="world"}
Object 2: {DATE=02.01.2012;A="hi";B="there"}
How would this be modelled as a persistent java class? I understand how it would be done if the table had DATE, A and B columns, but am too new to hibernate to know how to resolve this. I envision the class would look like the following:
Code:
@Entity // would this be an Entity type of object??
@Table(name="MyTable")
public MyObject {
@Id
@Column(name="DATE")
private Date date;
@Column(name="VALUE") // is there some annotation or construct like: where Column(name="TYPE)="A"
private String a;
@Column(name="VALUE") // as above
private String b;
...other code...
}
Do I need to make some sort of mapping class or xml file to make this work?
Any help would be appreciated.