The given object has a null identifier,做页面更新,id丢失

org.springframework.dao.InvalidDataAccessApiUsageException: The given object has a null identifier: com.chuai.pojo.Role; nested exception is org.hibernate.TransientObjectException: The given object has a null identifier: com.chuai.pojo.Role
在这里插入图片描述
原因:从更新页面跳转到更新方法,id丢失
在这里插入图片描述
解决: update的时候是struts2 提交表单自己封装的一个实体 update(entity)
封装的实体对象的主键对应属性没有赋值
因此更新的页面要放一个保存主键值(从上一个页面来的),然后封装实体的时候,把主键值设置进去。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44142296/article/details/85054823