-1
In my study project, aimed at controlling football matches, I have the following entities:
Gambler
- Name;
Departure
- Date of implementation;
- Gols pro;
- Goals against;
I still need to record the goals of the match per player, what should be on the bench this way:
Jogador PartidaJogador Partida
(id,nome) (jogador_id, partida_id, numeroGols) (id,data...)
Below the already created classes:
@Entity
public class Jogador implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
private String nome;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
@Override
public String toString() {
return nome;
}
}
@Entity
public class Partida implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotNull
private String adversario;
@NotNull
private LocalDate dataRealizacao;
@Min(0)
@NotNull
private Integer golsPro;
@Min(0)
@NotNull
private Integer golsContra;
@OneToMany
private Set<PartidaJogador> jogadoresGols = new HashSet<>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAdversario() {
return adversario;
}
public void setAdversario(String adversario) {
this.adversario = adversario;
}
public LocalDate getDataRealizacao() {
return dataRealizacao;
}
public void setDataRealizacao(LocalDate dataRealizacao) {
this.dataRealizacao = dataRealizacao;
}
public Integer getGolsPro() {
return golsPro;
}
public void setGolsPro(Integer golsPro) {
this.golsPro = golsPro;
}
public Integer getGolsContra() {
return golsContra;
}
public void setGolsContra(Integer golsContra) {
this.golsContra = golsContra;
}
public Set<PartidaJogador> getJogadoresGols() {
return jogadoresGols;
}
public void setJogadoresGols(Set<PartidaJogador> jogadoresGols) {
this.jogadoresGols = jogadoresGols;
}
}
The basic flow should be the creation of matches, so I need to save the Match object and save the related entity Partidaplayer as well.
How to map the table PartidaJogador with the extra column numeroGols?
How about posting the class code Partidajogador?
– Caffé