我們已經從sqlite的切換到火鳥嵌入式服務器,因爲FB 似乎支持數據庫的併發更新,但我們有時 有這些例外,從它的到來:用NHibernate設置正確的事務隔離模式,如何?
2010-10-28 15:49:31,242 [56] ERROR NetworkCatcher.Entities.Agent.Server.RunResultManager - Failed to send result to server 32W2K3SP2VM-DEV. NHibernate.Exceptions.GenericADOException: could not update: ExecutionEntry#89_19_32W2K3SP2VM-DEV][SQL: UPDATE Run SET ExecutionId = ?, Source = ?, Destination = ?, ProtocolId = ?, Duration = ?, SampleCount = ?, StartTime = ?, ServerHostName = ?, SamplesSentToServer = ?, SampleInterval = ?, Parameters = ? WHERE Id = ?] ---> FirebirdSql.Data.FirebirdClient.FbException: deadlock
update conflicts with concurrent update
concurrent transaction number is 31632 --->
FirebirdSql.Data.Common.IscException: deadlock
update conflicts with concurrent update
concurrent transaction number is 31632
at FirebirdSql.Data.Client.Native.FesDatabase.ParseStatusVector(IntPtr[]
statusVector)
at FirebirdSql.Data.Client.Native.FesStatement.Execute()
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior
behavior, Boolean returnsSet)
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior
behavior)
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteNonQuery()
.
.
.
的FB響應,這是 「你爲什麼認爲這是一個錯誤?這是一個定期更新衝突,導致 由兩個事務同時更新相同的記錄。什麼是 事務隔離模式「
,這句話一直困擾着我兩次 - 一次,因爲我是不愉快 驚訝地發現,我在上面寫上同時相同的記錄 和第二次 - 我不知道是什麼我 事務隔離模式和如何使用它序列寫入 相同的記錄。
對象的映射,被更新爲:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-
import="true">
<class name="NetworkCatcher.Entities.Agent.Server.ExecutionManager+ExecutionEntry,NC.Entities.Agent.Server" lazy="false" table="Run" entity-name="ExecutionEntry">
<id name="Id" column="Id" type="string" >
<generator class="assigned"/>
</id>
<property name="ExecutionId"/>
<property name="Source"/>
<property name="Destination"/>
<property name="ProtocolId" type="string"/>
<property name="Duration"/>
<property name="SampleCount"/>
<property name="StartTime"/>
<property name="ServerHostName"/>
<property name="m_samplesSentToServer" column="SamplesSentToServer" type="int" access="field" />
<property name="SampleInterval"/>
<property name="Parameters" type="binary"/>
</class>
</hibernate-mapping>
我相信有好心人在那裏,誰知道答案 我的問題。請,請,請從你的智慧分享...
感謝。