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
The given object has a null identifier,做页面更新,id丢失
原因:从更新页面跳转到更新方法,id丢失
The given object has a null identifier,做页面更新,id丢失
解决: update的时候是struts2 提交表单自己封装的一个实体 update(entity)
封装的实体对象的主键对应属性没有赋值
因此更新的页面要放一个保存主键值(从上一个页面来的),然后封装实体的时候,把主键值设置进去。
The given object has a null identifier,做页面更新,id丢失