OneToOne 实体映射删除操作不起作用

OneToOne entity mapping delete operation not working

我有一个群组成员 table,当我尝试从群组成员 table 中删除记录时,它以一对一的关系绑定到用户 table , 没有任何反应。

我的GroupsTable

public class Groups implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotBlank
    @Column(unique = true)
    private String groupName;

    @OneToMany(fetch = FetchType.LAZY, orphanRemoval = false, mappedBy = "group")
    private List<GroupMembers> members;
}

Group Members Table

public class GroupMembers implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "group_id", nullable = false)
    private Groups group;

    @OneToOne
    @JoinColumn(name = "user_id", nullable = false)
    private User user;
}

Users Table

public class User implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String firstName;

    @OneToOne(fetch = FetchType.LAZY, mappedBy = "commutersInfo", cascade = CascadeType.ALL, orphanRemoval = true)
    private GroupMembers groupMembers;
}

当我尝试以下删除记录时没有任何反应

groupsMembersRepository.delete(groupsMembersRepository.findByUserEmail(email));

没有错误,控制台中没有调试信息,只是没有从数据库中删除记录

出于某种原因,JPA 没有 运行 执行我的删除命令,当我执行此操作时 spring.jpa.show-sql=true,我看到了所有 select 查询,而 JPA 没有 运行 我的删除查询,我不知道为什么,但我想要一些解释。

最终我不得不使用这个

@Modifying
    @Query(value = "DELETE FROM `group_members` WHERE `commuters_info_id` = ?1", nativeQuery = true)
    public void deleteByCommutersInfoEmail(long id);