title: JPA OneToOne cascade delete
body: <p>i have a rellationship between 2 classes Document and Medecin </p>
  
  <pre><code>@Entity
  public class Document implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
      private String annee;
      private Date dateVisite;
      private String secteur;
      private String typeVisite;
      @OneToOne( fetch=FetchType.LAZY,cascade=CascadeType.REMOVE)
      @JoinColumn(name = "idMedecin")
  
      private Medecin medecin;
  
      public Document(String annee, 
              Date dateVisite, String secteur, String typeVisite) {
          super();
          this.annee = annee;
          this.dateVisite = dateVisite;
          this.secteur = secteur;
          this.typeVisite = typeVisite;
      }
  
      public String getSecteur() {
          return secteur;
      }
  
      public void setSecteur(String secteur) {
          this.secteur = secteur;
      }
  
      public String getTypeVisite() {
          return typeVisite;
      }
  
      public void setTypeVisite(String typeVisite) {
          this.typeVisite = typeVisite;
      }
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getAnnee() {
          return annee;
      }
  
      public void setAnnee(String annee) {
          this.annee = annee;
      }
  
      public Date getDateVisite() {
          return dateVisite;
      }
  
      public void setDateVisite(Date dateVisite) {
          this.dateVisite = dateVisite;
      }
  
  }
  </code></pre>
  
  <p>and the medecin entity is</p>
  
  <pre><code>@Entity
  public class Medecin implements Serializable {
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private long id;
      private String nom;
      private String secteur;
      private int telephone;
      private int specialite;
  
      public Medecin() {
          super();
          // TODO Auto-generated constructor stub
      }
  
      public Medecin(String nom, String secteur, int telephone, int specialite) {
          super();
          this.nom = nom;
          this.secteur = secteur;
          this.telephone = telephone;
          this.specialite = specialite;
      }
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getNom() {
          return nom;
      }
  
      public void setNom(String nom) {
          this.nom = nom;
      }
  
      public String getSecteur() {
          return secteur;
      }
  
      public void setSecteur(String secteur) {
          this.secteur = secteur;
      }
  
      public int getTelephone() {
          return telephone;
      }
  
      public void setTelephone(int telephone) {
          this.telephone = telephone;
      }
  
      public int getSpecialite() {
          return specialite;
      }
  
      public void setSpecialite(int specialite) {
          this.specialite = specialite;
      }
  }
  </code></pre>
  
  <p>the problem is that after i generate the database i want if i delete the document record from the database i want the medecin record will be deleted also but in my case if i delete the document record the medecin record dont be deleted</p>