title: Spring Data JPA : Repository DeleteById method not working
body: <p>I have an issue which I do not understand with my Spring Data JPA Repository. I have the following entity :</p>
  <pre class="lang-java prettyprint-override"><code>
  @Entity
  public class Ability {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Integer id;
      private String name;
      private String color;
      private String image;
  
      @ManyToOne(
              fetch = FetchType.EAGER
      )
      private Subject subject;
  
      @OneToMany(
              mappedBy = &quot;ability&quot;,
              cascade = CascadeType.ALL,
              orphanRemoval = true,
              fetch = FetchType.EAGER
      )
      private Set&lt;Technology&gt; technologies;
  </code></pre>
  <p>And a JPA Repository for this entity.
  What I dot not understand, is that when I use the <code>deleteById</code> method of my Jpa Repository, the record is not deleted from the database. Strange thing is that it works fine in my integration test using an InMemory database.
  It works if I override the <code>deleteById</code> with the following :</p>
  <pre class="lang-java prettyprint-override"><code>    @Modifying
      @Query(&quot;DELETE FROM Ability a WHERE a.id = :id&quot;)
      void deleteById(@Param(&quot;id&quot;) Integer id);
  </code></pre>
  <p>But I suspect I shouldn't have to do that. Any clue with the method does not work as expected ?</p>
  <p>EDIT : Add endpoint source code</p>
  <pre class="lang-java prettyprint-override"><code>@RestController
  @RequestMapping(&quot;/subjects/{subjectId}/abilities&quot;)
  public class AbilityController {
      ...
      
      private final AbilityRepository abilityRepository;
      private final TechnologyRepository technologyRepository;
      private final SubjectRepository subjectRepository;
  
      public AbilityController(AbilityRepository abilityRepository, TechnologyRepository technologyRepository, SubjectRepository subjectRepository) {
          this.abilityRepository = abilityRepository;
          this.technologyRepository = technologyRepository;
          this.subjectRepository = subjectRepository;
      }
  
      @DeleteMapping(&quot;{abilityId}&quot;)
      @ResponseStatus(HttpStatus.NO_CONTENT)
      public void deleteAbility(@PathVariable(&quot;subjectId&quot;) Integer subjectId, @PathVariable(&quot;abilityId&quot;) Integer abilityId) {
          if (!abilityRepository.existsAbilityBySubjectId(subjectId, abilityId)) {
              throw new ResourceNotFoundException(String.format(&quot;No ability with Id : %s&quot;, abilityId));
          }
  
          abilityRepository.deleteById(abilityId);
      }
      ...
  }
  </code></pre>
  <p>EDIT : Add Hibernate SQL</p>
  <pre class="lang-sql prettyprint-override"><code>Hibernate: 
      select
          ability0_.id as id1_0_0_,
          ability0_.color as color2_0_0_,
          ability0_.image as image3_0_0_,
          ability0_.name as name4_0_0_,
          ability0_.subject_id as subject_5_0_0_,
          subject1_.id as id1_7_1_,
          subject1_.icon as icon2_7_1_,
          subject1_.image as image3_7_1_,
          subject1_.name as name4_7_1_,
          technologi2_.ability_id as ability_4_8_2_,
          technologi2_.id as id1_8_2_,
          technologi2_.id as id1_8_3_,
          technologi2_.ability_id as ability_4_8_3_,
          technologi2_.image as image2_8_3_,
          technologi2_.name as name3_8_3_ 
      from
          ability ability0_ 
      left outer join
          subject subject1_ 
              on ability0_.subject_id=subject1_.id 
      left outer join
          technology technologi2_ 
              on ability0_.id=technologi2_.ability_id 
      where
          ability0_.id=?
  Hibernate: 
      select
          abilities0_.subject_id as subject_5_0_0_,
          abilities0_.id as id1_0_0_,
          abilities0_.id as id1_0_1_,
          abilities0_.color as color2_0_1_,
          abilities0_.image as image3_0_1_,
          abilities0_.name as name4_0_1_,
          abilities0_.subject_id as subject_5_0_1_ 
      from
          ability abilities0_ 
      where
          abilities0_.subject_id=?
  Hibernate: 
      select
          technologi0_.ability_id as ability_4_8_0_,
          technologi0_.id as id1_8_0_,
          technologi0_.id as id1_8_1_,
          technologi0_.ability_id as ability_4_8_1_,
          technologi0_.image as image2_8_1_,
          technologi0_.name as name3_8_1_ 
      from
          technology technologi0_ 
      where
          technologi0_.ability_id=?
  </code></pre>
  <p>Thanks in advance</p>