【问题标题】:cannot update a record Hibernate无法更新记录休眠
【发布时间】:2016-12-23 07:22:29
【问题描述】:

org.hibernate.StaleStateException:批量更新从更新 [0] 返回了意外的行数;实际行数:0;预计:1

public class QuoteRequest implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long quoteRequestId = null;

}

quoteRequestEntity = quoteRequestDao.update(quoteRequestEntity);

当我尝试更新我的报价请求时,我收到了上述错误。我并不了解我的映射有什么问题。有人可以帮忙吗?

【问题讨论】:

  • 我认为这意味着您的更新无法运行。你需要检查你的quoteRequestEntity
  • 你能告诉我们你是如何填充你的quoteRequestEntity对象的吗?

标签: java hibernate orm


【解决方案1】:

我认为这是因为quoteRequestIdnull

您应该在您的quoteRequestId 上设置一个值,因为当您更新您的实体时,它不会在其上生成 ID,它只会在您 INSERT 时生成记录。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 2018-02-25
    • 2012-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多