Discuss / Java / 尊敬的廖大佬,OrderEntity 的 updateOrder 方法里 this.version++ 执行了两次是何用意啊?

尊敬的廖大佬,OrderEntity 的 updateOrder 方法里 this.version++ 执行了两次是何用意啊?

Topic source

何霖

#1 Created at ... [Delete] [Delete and Lock User]

public void updateOrder(BigDecimal unfilledQuantity, OrderStatus status, long updatedAt) {

this.version++;

this.unfilledQuantity = unfilledQuantity;

this.status = status;

this.updatedAt = updatedAt;

this.version++;

}

廖雪峰

#2 Created at ... [Delete] [Delete and Lock User]

为了读的时候检测版本改动,为啥加两是为了能在写完之前检测到改动,具体我也没测,感觉可以把第一个version++去了


  • 1

Reply