我需要一些非常严重的问题的帮助,所以事情是我有ae商务网站,一次单个用户下订单工作正常,但如果不止一个用户尝试订购相同的产品,那么我我得到了这个例外
org.grails.datastore.mapping.core.OptimisticLockingException: The instance was updated by another user while you were editing
Point : in.emkart.api.OrderAPIController.save(OrderAPIController.groovy:70)
所以我的代码就像
/** some code **/
if (product && orderContinue) {
product = updateQuantityForProduct(product)
order?.product = product
/** some code **/
try{
// some code
product.save() // line 70
// some code
}
catch(Exception e){
log.debug "unable to place order-->"+e /** exception --> (unable to place order-->org.grails.datastore.mapping.core.OptimisticLockingException: The instance was updated by another user while you were editing
Point : in.emkart.api.OrderAPIController.save(OrderAPIController.groovy:70) ) **/
}
哪些修复可以帮助我防止这种情况,也可以让另一个用户等待或保持某种队列,以便一旦先前的订单完成,那么只有下一个请求继续下订单。< / p>