我尝试在Grails的服务保存对象MongoDB中:Grails的格罗姆+ MongoDB中得到
Cover saveCover = new Cover()
saveCover.id = url
saveCover.url = url
saveCover.name = name
saveCover.sku = sku
saveCover.price = price
saveCover.save()
封面域看起来是这样的:
class Cover {
String id
String name
String url
String sku
String price
}
所以我想有自定义ID基于网址,但在保存过程中我得到错误:
Could not commit Datastore transaction; nested exception is org.grails.datastore.mapping.core.OptimisticLockingException: The instance was updated by another user while you were editing
但我没有使用setters,只是通过所有值在构造函数中,这个异常消失了。为什么?
我不明白GORM默认为什么这么认为。你能解释一下吗? – sphinks
我已经更新了关于为什么gorm认为这个更详细的问题。 – PaddyDwyer