SpringBoot-JPA删除不成功,只执行了查询语句
2024-10-19 20:24:31
今天使用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=?
最新文章
- QT特供 CGAL配置流程(基于QT5+VS2015)
- js中数组
- Data层相关问题 &; JS循环取值
- 【BZOJ】【1009】 【HNOI2008】GT考试
- SVN设置实例
- Delphi的";Invalid pointer operation";异常的解决办法
- struct 如何存储指针类型的值
- 遍历Map集合:java.util.Map.Entry、KeySet两种方式
- ElasticSearch之 控制相关度原理讲解
- 面试题-Python高级
- python排序算法之冒泡,选择,插入
- 【51Nod1405】树上距离和 二次扫描与换根法
- shell函数与数组
- 在Docker Swarm上部署Apache Storm:第1部分
- Mac OS X下的移动光标和文字编辑快捷键
- POJ-2777 Count Color(线段树,区间染色问题)
- URL地址理解
- Wince 中访问WCF服务
- Ubuntu 12.04 Subversion及GUI客户端RabbitVCS安装
- netty之粘包分包的处理