2
我正在構建一個MultiLingual應用程序,其中包含一些動態翻譯。因此,我選擇爲產品製作單獨的表格,其中包括翻譯。NHibernate不插入兒童
不,我無法插入翻譯,他們是產品的一部分。插入哪個。
<class name="Product" table="Product">
<id name="Id">
<generator class="native" />
</id>
<property name="SomeOtherStuff" column="SomeOtherStuff" />
<set name="NaamTranslations" cascade="all">
<key column="ProductId" not-null="true" />
<one-to-many class="ProductTranslation" />
</set>
</class>
<class name="ProductTranslation"
table="ProductTranslation" lazy="false">
<id name="Id">
<generator class="native" />
</id>
<many-to-one name="Product" column="ProductId" not-null="true"
index="UQ_ProductTranslation" class="Product"
cascade="all-delete-orphan" />
<property name="CultureCode" column="LanguageCode"
not-null="true" index="UQ_ProductTranslation" />
<property name="Name" column="Name" not-null="true" />
</class>
我的猜測是這個問題是在NHibernate的配置中的某個地方。因爲我可以在整個代碼中遵循產品的創建。此外,我還將show_sql放在了上面,它顯示了產品的創建,但缺少ProductTranslations的插入。
INSERT INTO dbo.Product (SomeOtherStuff) VALUES (@p0);
select SCOPE_IDENTITY(); @p) = 'Hello this is a test' [Type: String (4000)]