Olá galera, estou desenvolvendo meu TCC e me deparei com o seguinte erro:
[color=red]Cannot add or update a child row: a foreign key constraint fails (sgct
.avaliacao
, CONSTRAINT fk_Avaliacao_Aluno1
FOREIGN KEY (fk_fk_idPessoa
) REFERENCES aluno
(fk_idPessoa
) ON DELETE NO ACTION ON UPDATE NO ACTION)[/color]
Classe Avaliacao:
[code]import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.ForeignKey;
@Entity
@Table(name=“Avaliacao”)
public class Avaliacao implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@Column(name="idAvaliacao", nullable=false)
private int idAvaliacao;
@Column(name="dataAvaliacao", nullable=false)
@Temporal(TemporalType.DATE)
private Date dataAvaliacao;
@Column(name="descricaoAvaliacao", nullable=false, length=45)
private String descricaoAvaliacao;
@Column(name="valorTotal", nullable=false)
private float valorTotal;
@Column(name="valorObtido", nullable=true)
private float valorObtido;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name="fk_fk_idPessoa", referencedColumnName="idPessoa", nullable=false)})
@ForeignKey(name="FK_AvaliacaoAluno")
private Aluno Aluno;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name="fk_idTurma", referencedColumnName="idTurma", nullable=false)})
@ForeignKey(name="FK_AvaliacaoTurma")
private Turma Turma;[/code]
Agora a classe Aluno que extende a Classe Pessoa:
[code]
import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumns;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import org.hibernate.annotations.ForeignKey;
@Entity
@Table(name = “Aluno”)
@PrimaryKeyJoinColumns(value={
@PrimaryKeyJoinColumn(name =“idPessoaAluno”, referencedColumnName =“idPessoa”)})
public class Aluno extends Pessoa implements Serializable{
private static final long serialVersionUID = 1L;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name="fk_idDesistencia", referencedColumnName="idDesistencia", nullable=true)})
@ForeignKey(name="fk_idDesistencia")
private Desistencia Desistencia;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "Aluno")
private List<AlunoTurma> AlunoTurma;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "Aluno")
private List<Avaliacao> Avaliacao;[/code]
O que pode ta acontecendo? O que eu poderia mudar pra consertar isso?