title: Spring Data JPA orphanRemoval not working
body: <p>I have an issue with deleting items from a Set using Spring Data JPA.
  I have three entities commercialepiece, commercialepieceIem,sellpiece the relationship is donc in this manner.
  commercialePiece 1 ----------> * commercialepieceitem.
  I'm using Postgresql as DBMS,</p>
  
  <p>Database schema is </p>
  
  <p>Entity commercialepieceitem</p>
  
  <pre><code>    CREATE TABLE public.commercialepieceitem
      (
        idpiece integer NOT NULL,
        idpieceitem integer NOT NULL DEFAULT nextval('commercialepieceitem_idpieceitem_seq'::regclass),
        idproduct integer NOT NULL,
        qty numeric,
        price numeric,
        name_h character varying(255),
        tax numeric,
        discount numeric,
        operationcode integer,
        CONSTRAINT pk_commercialepieceitem PRIMARY KEY (idpiece, idpieceitem),
        CONSTRAINT fk_commerci_affecte_product FOREIGN KEY (idproduct)
            REFERENCES public.product (idproduct) MATCH SIMPLE
            ON UPDATE NO ACTION ON DELETE NO ACTION,
        CONSTRAINT fk_commerci_construit_commerci FOREIGN KEY (idpiece)
            REFERENCES public.commercialepiece (idpiece) MATCH SIMPLE
            ON UPDATE NO ACTION ON DELETE NO ACTION
      )
      WITH (
        OIDS=FALSE
      );
      ALTER TABLE public.commercialepieceitem
        OWNER TO postgres;
  </code></pre>
  
  <p>Entity commercialepiece</p>
  
  <pre><code>CREATE TABLE public.commercialepiece
  (
    idpiece integer NOT NULL DEFAULT nextval('commercialepiece_idpiece_seq'::regclass),
    idtva integer,
    idsession integer,
    numpiece character varying(30),
    datepiece date,
    status character varying(20),
    observation text,
    dateecheance date,
    discount numeric,
    CONSTRAINT pk_commercialepiece PRIMARY KEY (idpiece),
    CONSTRAINT fk_commerci_appliquer_tva FOREIGN KEY (idtva)
        REFERENCES public.tva (idtva) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION,
    CONSTRAINT fk_commerci_require_comptoir FOREIGN KEY (idsession)
        REFERENCES public.comptoirsession (idsession) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION
  )
  WITH (
    OIDS=FALSE
  );
  ALTER TABLE public.commercialepiece
    OWNER TO postgres;
  </code></pre>
  
  <p>After mapping this one to many bidirectionnal relationship : </p>
  
  <pre><code>@Entity
  @Table(name = "commercialepiece")
  @Inheritance(strategy = InheritanceType.JOINED)
  public abstract class CommercialePiece {
   @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "idpiece")
      private Long idPiece;
       @OneToMany(mappedBy = "commercialepiece", cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.EAGER)
      private Set&lt;CommercialePieceItem&gt; pieceItems = new HashSet&lt;&gt;();
  
  // Getter and setters and other attributes removed simplicity purprose
  }
  
  
  @Entity
  @Table(name = "commercialepieceitem")
  public class CommercialePieceItem  {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "idpieceitem")
      private Long idPieceItem;
  
    @ManyToOne()
     @JoinColumn(name = "idpiece")
      private CommercialePiece commercialepiece;
  
  // Getter and setters and other attributes removed simplicity purprose
    }
  
  
  @Entity
  @Table(name = "sellpiece")
  @PrimaryKeyJoinColumn(name = "idpiece")
  public class SellPiece extends CommercialePiece {
  
  }
  </code></pre>
  
  <p>I have tried to to use some annotations like @OnDelete(action = OnDeleteAction.CASCADE), but no thing works.</p>
  
  <p>So, what the right way to delete Orpahs ? </p>