title: Spring Data delete function not deleting records
body: <p>I have the following simple application</p>
  
  <p><code>Users</code> Entity</p>
  
  <pre><code>@Entity
  public class Users implements Serializable {
  
     @Id
     @GeneratedValue
     private long id;
  
     private String name;
  
     @OneToMany(mappedBy = "user", fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
     private Set&lt;UserRoleUser&gt; userRoleUser;
  
     // GETTERS AND SETTERS
  }
  </code></pre>
  
  <p><code>UserRole</code> Entity</p>
  
  <pre><code>@Entity
  public class UserRole implements Serializable {
  
     @Id
     @GeneratedValue
     private long id;
  
     private String roleName;
  
     @OneToMany(mappedBy = "userrole", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
     private Set&lt;UserRoleUser&gt; userRoleUser;
  
     // GETTERS AND SETTERS
  }
  </code></pre>
  
  <p><code>UserRoleUser</code> Many to many resolver class</p>
  
  <pre><code>@Entity
  public class UserRoleUser implements Serializable {
  
     @Id
     @GeneratedValue
     private long id;
  
     @ManyToOne
     @JoinColumn(name = "fk_userId")
     private Users user;
  
     @ManyToOne
     @JoinColumn(name = "fk_userroleId")
     private UserRole userrole;
  
     // GETTERS AND SETTERS
  }
  </code></pre>
  
  <p><code>UserRoleUserRepository</code></p>
  
  <pre><code>@Repository
  @Transactional
  public interface UserRoleUserRepository extends JpaRepository&lt;UserRoleUser, Long&gt;, QueryDslPredicateExecutor&lt;UserRoleUser&gt;{
  
  }
  </code></pre>
  
  <p>Main <code>Application</code> class</p>
  
  <pre><code>@SpringBootApplication
  @Configuration
  public class Application {
  
     public static void main(String[] args) {
         ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
  
         UserRoleUserRepository userRoleUserRepository = context.getBean(UserRoleUserRepository.class);
  
         Iterable&lt;UserRoleUser&gt; findAll = userRoleUserRepository.findAll(QUserRoleUser.userRoleUser.id.gt(0));
  
         for (UserRoleUser userRoleUser : findAll) {
             userRoleUserRepository.delete(userRoleUser);
         }
  
     }
  
  }
  </code></pre>
  
  <p>On running the <code>main</code> application, the database records in the <code>UserRoleUser</code> table are not being deleted. What could be the issue? I am using <code>Spring Data</code> and <code>QueryDsl</code>.</p>
  
  <p>I have also tried putting the delete functionality on a <code>Controller</code> but still doesn't work.</p>
  
  <pre><code>@RestController
  @RequestMapping("/api")
  public class DeleteController {
  
      @Autowired
      UserRoleUserRepository userRoleUserRepository;
  
      @GetMapping("/delete")
      public String delete() {
          Iterable&lt;UserRoleUser&gt; findAll = userRoleUserRepository.findAll(QUserRoleUser.userRoleUser.id.gt(0));
  
          for (UserRoleUser userRoleUser : findAll) {
              userRoleUserRepository.delete(userRoleUser);
          }
  
          return new Date().toString();
      }
  }
  </code></pre>