问题描述
升级CommentUser 独立后,部分CommentUser 实体为空,无论我删除,还是@Transient,LAZY、@NotFound(action= NotFoundAction.IGNORE) 依然报错。
@Column
private Long userId;
@ManyToOne
@JoinColumn(name = "userId",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT)
,updatable = false,insertable = false)
private static CommentUser commentUser;
报错
{
"timestamp": "2019-10-23 15:09:21",
"status": 500,
"error": "Internal Server Error",
"message": "Unable to find cn.hitstone.comment.entity.CommentUser with id 1791; nested exception is javax.persistence.EntityNotFoundException: Unable to find cn.hitstone.comment.entity.CommentUser with id 1791",
"path": "/comments"
}
排查过程
在我删除 private static CommentUser commentUser; 依然报错,我开始怀疑是不是数据库索引的问题。删除索引还是跪了。排查hibernate 版本,最后看sql发现子类包含了。心累。
解决方法
最终使用@NotFound(action= NotFoundAction.IGNORE) 解决了问题。
网友评论