Fluent Nhibernate Optimistick 锁定不起作用
在我的应用程序中,我已将应用程序设置为使用该策略来防止 2 个不同的对话处理相同的数据。但不起作用,我不知道为什么。
问题:
1) User1:
Retrive rowversion from database: 0x00000000001063B0
Do some modification
2) User2:
Retrive rowversion from database: 0x00000000001063B0
Do some modification
3) User1:
Update the data
New rowversion: 0x00000000001063B2
4) User2:
Update the data
Should trown a StaleObjectStateException,
but the rowversion is updated to 0x00000000001063B4
配置:
我的应用程序中有 Fluent Nhibernate 配置:
public static ClassMap<T> RowVersionTracking<T>(this ClassMap<T> classMap) where T : DomainObject
{
classMap.OptimisticLock.Version();
classMap
.Version(x => x.RowVersion)
.Column(DomainObject.VersionPropertyName)
.CustomType("BinaryBlob")
.CustomSqlType("timestamp")
.Generated.Always()
.UnsavedValue("null");
return classMap;
}
例如,当我保存继承此属性的 CustomerOrder 实例时:
在映射中具有:
...
this.RowVersionTracking();
...
最好的问候, 铁托
In my application I have set the application to use the strategy to prevent 2 different conversations to work at the same data. But is not working, I don't know why.
PROBLEM:
1) User1:
Retrive rowversion from database: 0x00000000001063B0
Do some modification
2) User2:
Retrive rowversion from database: 0x00000000001063B0
Do some modification
3) User1:
Update the data
New rowversion: 0x00000000001063B2
4) User2:
Update the data
Should trown a StaleObjectStateException,
but the rowversion is updated to 0x00000000001063B4
CONFIGURATION:
I have in my application the Fluent Nhibernate configuration:
public static ClassMap<T> RowVersionTracking<T>(this ClassMap<T> classMap) where T : DomainObject
{
classMap.OptimisticLock.Version();
classMap
.Version(x => x.RowVersion)
.Column(DomainObject.VersionPropertyName)
.CustomType("BinaryBlob")
.CustomSqlType("timestamp")
.Generated.Always()
.UnsavedValue("null");
return classMap;
}
And when I save for example, an instance of CustomerOrder that inherits this property:
Has in the mappings:
...
this.RowVersionTracking();
...
best regards,
Tito
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论