我已经从JPA带注释的实体类生成了我的数据库表,如下所示:
@Entity
@Table (name="chauffeur")
public class Chauffeur{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MYNOTIFSEQ") //identificateur de de la séquence
@SequenceGenerator(name = "MYNOTIFSEQ", sequenceName = "MY_SEQ") //nom de la séquence dans la base
private Long id; // Identifiant formation (Clé primaire)
private String nom;
private String prenom;
private String adresse;
private String telephone;
private String login;
private String motdepasse;
private String position;
private String disponible;
@OneToOne(mappedBy = "c")
private Taxi t;
@OneToOne(mappedBy = "chau")
private Favoris favoris;
和这堂课:
@Entity
@Table(name = "favoris")
public class Favoris {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MYNOTIFSEQ")
@SequenceGenerator(name = "MYNOTIFSEQ", sequenceName = "MY_SEQ")
private Long id; // Identifiant formation (Clé primaire)
@OneToOne(cascade={CascadeType.PERSIST, CascadeType.REMOVE},orphanRemoval=true)
private Taxi taxi;
@OneToOne(cascade={CascadeType.PERSIST, CascadeType.REMOVE},orphanRemoval=true)
private Chauffeur chau;
我的问题是我想从Chauffeur表中删除一行,但是这个表引用了Favoris表 这就是我有这个错误的原因:
java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (MYBASE.FK_SUIDVMBNQQO4MUFI27VCLVPMV) violated - child record found
这是我使用的查询:
delete from Chauffeur where id ='1'
我该如何解决问题,谢谢