We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题1:ArticleServiceImpl.java 102行,应修改为:
if (!Objects.equals(authenticateUser.getId(), article.getAuthor().getId())) { throw new ForbiddenException("无权限删除该文章"); }
注意:非java原生类型,请勿使用.equals函数进行等值判断 ———————————————— 问题2:当用户删除已有历史记录的文章时,由于history表中的含有其外键,SQL不允许父级删除。 请尝试修改为级联删除,或取消外键级联关系
错误详情: java.sql.SQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (frogsoft_cms_db.history, CONSTRAINT FK2vowuipf9ugvhyk8nwigfu6si FOREIGN KEY (article_id) REFERENCES article (id))
java.sql.SQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (
.
, CONSTRAINT
FOREIGN KEY (
) REFERENCES
(
))
The text was updated successfully, but these errors were encountered:
更新:删除用户也有同样的问题,用户创建的文章不能同步删除
Sorry, something went wrong.
// fix:级联删除问题 @OneToMany(cascade = CascadeType.ALL) @JoinColumn(name = "author") @OnDelete(action = OnDeleteAction.CASCADE) private Set<Article> articles;
以上是对User-Article一对多对多的外键添加方法, 理论上,每一个多对多,都要添加如上外键 结果有待后期测试
gjjjj0101
No branches or pull requests
问题1:ArticleServiceImpl.java 102行,应修改为:
注意:非java原生类型,请勿使用.equals函数进行等值判断
————————————————
问题2:当用户删除已有历史记录的文章时,由于history表中的含有其外键,SQL不允许父级删除。
请尝试修改为级联删除,或取消外键级联关系
错误详情:
java.sql.SQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (
frogsoft_cms_db.
history, CONSTRAINT
FK2vowuipf9ugvhyk8nwigfu6siFOREIGN KEY (
article_id) REFERENCES
article(
id))
The text was updated successfully, but these errors were encountered: