Hibernate version: 3.6.7.Final
Hibernate annotations version: 3.2.0.Final
I am trying to map classes over a pre-existing database that I cannot change. There is a parent table X and a child table Y. Y has a foreign key to X and another column that form a composite key.
Classes look like this:
Code:
@Entity
@Table(name = "X")
public class X {
@Id
@Column(name = "ID")
private Integer id;
// Getters & setters
}
@Embeddable
public class YKey {
@ManyToOne
@JoinColumn(name = "X_ID")
private X x;
@Column(name = "ORD")
private Integer order;
// Getters and setters
}
@Entity
@Table(name = "Y")
public class Y {
@Id
private YKey yKey;
// Other fields
// Getters and setters
}
How do I map the collection of Y's in class X using annotations?
It should be a List that is ordered by YKey.order
Thanks in advance.