I have a design model with 2 classes: Game
and Highscore
. The relationship between them is: a game can have 0 or many highscores. So, I'm trying to define class Highscore as @Embeddable
and inside Game I write:
@Embedded
private List<Highscore> highscores = new ArrayList<Highscore>();
The problem is that I get the following error from Eclipse: java.util.List is not mapped as an embeddable
.
Does anybody know what can be done?
Game:
@Entity
@Table(name="games")
public class Game {
@Id
private String name;
@Column(name="highscore_table_size")
private Integer highscoreTableSize;
private String url;
@Embedded
private List<Highscore> highscores = new ArrayList<Highscore>();
...
}
Highscore:
@Embeddable
public class Highscore {
private String playerName;
private Date date;
private int score;
// getters and setter
}
EDIT: I also had a Table xyz cannot be resolved
error from Eclipse and, searching for a solution, I've found this, and turning off the JPA validator for Build did the trick also for the error presented in this post.