【MySQL用JPA批量删除】check the manual that corresponds to your MySQL server version for the right syntax错误

错误的语句:
    @Query(value = "delete from Topic t where t.topicIndustry.id=?", nativeQuery = true)
   void  deleteByTopicIndustry(@param("id")int id);


修改后的语句:
            
    @Query( "delete from Topic t where t.topicIndustry.id = ?1")
    @Transactional
    @Modifying
    void  deleteByTopicIndustry(int id);

仅仅是一个占位符的问题,找的好辛苦啊。。。

还有:注意一下,

@Query中 nativeQuery=true 表示为原生Sql不能与Pageable一起使用,所以用sql的limit|来实现分页查询。

pps:

@Modifying、@Transactional
注解 可千万别忘了哦~~~

猜你喜欢

转载自blog.csdn.net/harry5508/article/details/80983152