任何人都有任何想法爲什麼NHibernate會這樣做?看起來對我來說很簡單,它顯然是在崩潰我的應用程序,因爲它試圖更新主鍵列。這是它正在做的。NHibernate連續發出INSERT和UPDATE
首先,它插入一條記錄:
INSERT INTO WidgetConfigurationPositions
(WidgetId,
TargetId)
VALUES (256 /* @p0 */,
'row1-column2' /* @p1 */)
select SCOPE_IDENTITY()
就在第二天的語句會發出進行了更新,該記錄!
UPDATE WidgetConfigurationPositions
SET WidgetConfigurationId = null,
TargetId = null
WHERE WidgetConfigurationId = 96 /* @p0 */
AND Id = 302 /* @p1 */
親愛的上帝爲什麼要這樣做?以下是該實體的相關配置:
<class name="Backplane.WidgetConfiguration, Backplane" table="WidgetConfigurations">
<id name="Id" column="Id">
<generator class="native" />
</id>
<property name="Name" column="ConfigurationName" />
<map name="Widgets" table="WidgetConfigurationPositions" cascade="all" lazy="false" fetch="select">
<key column="WidgetConfigurationId" />
<index column="TargetId" type="string" />
<one-to-many class="Backplane.WidgetPlacement"/>
</map>
</class>
<class name="Backplane.WidgetPlacement, Backplane" table="WidgetConfigurationPositions">
<id name="Id" column="Id">
<generator class="native" />
</id>
<many-to-one name="Widget" class="Backplane.Widget, Backplane" column="WidgetId" lazy="false" />
<property name="Target" column="TargetId" />
<map name="Options" table="PlacedWidgetOptions" cascade="all" lazy="false" fetch="select">
<key column="WidgetConfigurationPositionId"/>
<index column="OptionName" type="string" />
<element column="OptionValue" type="string" />
</map>
</class>
我在配置中錯過了什麼嗎?
你怎麼稱呼,導致插入的代碼和更新? – 2010-07-04 07:08:15