I have four entities (selection, start, bet and bettor) where within the Bet class I have the IDs of a bet and a bettor. When I try to insert a bet by loading the game and the bettor into it, it gives me the following error:
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save ():
Bet Class
public class Aposta implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "idAposta")
private Integer idAposta;
@Size(max = 3)
@Column(name = "Palpite")
private String palpite;
@Size(max = 1)
@Column(name = "Status")
private String status;
@JoinColumn(name = "Apostador_idApostador", referencedColumnName = "idApostador")
@ManyToOne(optional = false, cascade = CascadeType.ALL)
private Apostador apostadoridApostador;
@JoinColumn(name = "Partida_idPartida", referencedColumnName = "idPartida")
@ManyToOne(optional = false, cascade = CascadeType.ALL)
private Partida partidaidPartida;
I think it's some mapping now I do not know which one. I found that I needed to add the cascade parameter inside @ManyToOne but it still did not roll.