错误的语句:
@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
注解可千万别忘了哦~~~