Hey. I'm trying to understand how to best design a set of tables in hibernate. For simplicity, I have two classes:
Code:
public class Security {
@Id
@Column
public String symbol;
public List<Earnings> earnings;
...
And
Code:
public class Earnings {
public Security security;
public Date date;
...
The Security has a OneToMany relationship with the Earnings Table. The Security only needs the symbol as the uniqueid, while the Earnings table would need the Symbol of the security plus a date to ensure uniqueness.
Now the question is how best to setup the relationship with hibernate and annotations.
Is it best to create a Composite Key in the Earnings and then use a OneToMany mapping using the composite key? If so, I get circular references.
How would you map the two entities?
Thanks in advance