【发布时间】:2015-12-13 08:18:32
【问题描述】:
我有下一个情况。我有 User 类,它是用于用户添加/编辑/删除的实体和绑定 JSP 表单 - 它有 3 个不同的按钮。我的问题是当我想编辑特定用户(我在表单中输入要编辑的用户名和字段)时,hibernate 会生成包含所有字段的 SQL 查询:
Hibernate: update users set user_age=?, user_country=?, user_email=?, user_login=?, user_name=?, user_password=?, user_status=? where user_id=?
问题是其他为空或为空。我得到错误:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
我怎样才能让休眠来生成这样的东西(如果我把新时代放入表单中):
Hibernate: update users set user_age=? where user_id=?
@DynamicUpdate(value=true) - 不起作用。我认为这种注释只适用于在登录表单分析和绑定之后未创建的对象。
【问题讨论】:
标签: java hibernate spring-mvc