今天使用JPA自定义了一个删除方法deleteByUserIdAndCommentId发现并没有删除掉对应的数据,只执行了查询语句

Hibernate: select good0_.id as id1_6_, good0_.commentId as commenti2_6_, good0_.userId as userid3_6_ from tbl_good good0_ where good0_.userId=? and good0_.commentId=?

解决方法:

在删除方法前加注解@Transactional即可

再次执行时会正常执行

Hibernate: select good0_.id as id1_6_, good0_.commentId as commenti2_6_, good0_.userId as userid3_6_ from tbl_good good0_ where good0_.userId=? and good0_.commentId=?
Hibernate: delete from tbl_good where id=?
Hibernate: select comment0_.id as id1_3_0_, comment0_.articleId as articlei2_3_0_, comment0_.ccomment as ccomment3_3_0_, comment0_.goodNum as goodnum4_3_0_, comment0_.userId as userid5_3_0_, comment0_.userType as usertype6_3_0_ from tbl_comment comment0_ where comment0_.id=?

参考链接:SpringBoot系列教程JPA之delete使用姿势详解

最新文章

  1. QT特供 CGAL配置流程(基于QT5+VS2015)
  2. js中数组
  3. Data层相关问题 & JS循环取值
  4. 【BZOJ】【1009】 【HNOI2008】GT考试
  5. SVN设置实例
  6. Delphi的"Invalid pointer operation"异常的解决办法
  7. struct 如何存储指针类型的值
  8. 遍历Map集合:java.util.Map.Entry、KeySet两种方式
  9. ElasticSearch之 控制相关度原理讲解
  10. 面试题-Python高级
  11. python排序算法之冒泡,选择,插入
  12. 【51Nod1405】树上距离和 二次扫描与换根法
  13. shell函数与数组
  14. 在Docker Swarm上部署Apache Storm:第1部分
  15. Mac OS X下的移动光标和文字编辑快捷键
  16. POJ-2777 Count Color(线段树,区间染色问题)
  17. URL地址理解
  18. Wince 中访问WCF服务
  19. Ubuntu 12.04 Subversion及GUI客户端RabbitVCS安装
  20. netty之粘包分包的处理

热门文章

  1. Kali Day1
  2. Java String的相关性质分析
  3. spring bean post processor
  4. 一.前后端分离及drf实现序列化的原理
  5. node 模块正确暴露方法
  6. wsl环境下配置ubuntu16.04
  7. WSL配置高翔vslam环境
  8. Netty 源码解析(七): NioEventLoop 工作流程
  9. Selenium之浏览器驱动下载和配置使用
  10. scala 数据结构(十一):流 Stream、视图 View、线程安全的集合、并行集合