I use the annotation hibernate i have thise source
@Table(name = "stats")
public class Stat {
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
private long id;
@ManyToOne(cascade = { CascadeType.REFRESH }, fetch = FetchType.LAZY)
@JoinColumn(name = "player_id")
private PPlayer player;
@Column(name = "stat_type")
private int type;
@Column(name = "stat_value")
private int value;
}
@Entity
@Table(name = "Users")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class PPlayer {
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
@Column(name = "user_id")
private long id;
private String username;
private String email;
private Date joiningDate;
private String key;
private String password;
private int rank;
private int score;
@OneToMany(mappedBy = "player", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
@MapKey(name = "type")
private Map<Integer, Stat> stats;
}
I watched a lot of documentation but I can not make out @MapKey
What means the name = "type"?
why "type"
? the class in which I can view it?
and where i can found mappedBy = "player"
?