Spring Data Repository does not delete ManyToOne Entity

前端 未结 6 633
陌清茗
陌清茗 2021-01-30 13:39

I\'m am currently trying to use a Spring Data repository to delete some of my entities. The delete call works without any exceptions/error messages, but the entity is not delete

6条回答
  •  终归单人心
    2021-01-30 14:17

    A simple alternative:

    @Repository
    public interface PostRepository extends CrudRepository {
    
    @Modifying(clearAutomatically = true, flushAutomatically = true)
    @Query(value = "DELETE FROM post WHERE id = ?1", nativeQuery = true)
    void deleteById(long postId);
    
    }
    

提交回复
热议问题