SpringBoot-JPA删除不成功,只执行了查询语句
2021-01-23 14:16
标签:tran lock sel 语句 from 删除 spring 查询语句 where 今天使用JPA自定义了一个删除方法 在删除方法前加注解 再次执行时会正常执行 参考链接:SpringBoot系列教程JPA之delete使用姿势详解 SpringBoot-JPA删除不成功,只执行了查询语句 标签:tran lock sel 语句 from 删除 spring 查询语句 where 原文地址:https://www.cnblogs.com/charlottepl/p/12883054.html
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=?
下一篇:关于Python中的yield
文章标题:SpringBoot-JPA删除不成功,只执行了查询语句
文章链接:http://soscw.com/index.php/essay/45926.html