我使用nhibernate來訪問我的數據庫,而andromda生成我的映射文件。 所有工作正常,只要我不使用可空數據類型。 我正在嘗試的是一個具有Nullables.NHibernate.NullableInt32Type類型屬性的實體。我的數據庫與類型爲「int NULL」(SQL Server)的列具有對應的關係。 對應的類也有正確的數據類型(int?)。 但是,當我試圖讓數據庫的價值,我得到一個NHibernate.MappingException:當使用可空類型時發生NHibernate.MappingException
NHibernate.MappingException:無效的映射信息指定 類型Namespace.SummaryAttribute,請檢查您的映射文件 屬性類型不匹配 ----> System.InvalidCastException:模板不可用。
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2"
default-cascade="none">
<class
name="Namespace.SummaryAttribute, Core"
table="SUMMARY_ATTRIBUTE"
dynamic-insert="false"
dynamic-update="false"
lazy="true">
<id name="Id" type="Int64" unsaved-value="0">
<column name="ID" sql-type="NUMERIC(19,0)"/>
<generator class="native">
</generator>
</id>
<property name="ShortName" type="String">
<column name="SHORT_NAME" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
</property>
<property name="LongName" type="String">
<column name="LONG_NAME" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
</property>
<property name="Description" type="String">
<column name="DESCRIPTION" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
</property>
<property name="IsVisible" type="Boolean">
<column name="IS_VISIBLE" not-null="true" unique="false" sql-type="BIT"/>
</property>
<property name="DecimalPlaces" type="Nullables.NHibernate.NullableInt32Type, Nullables.NHibernate">
<column name="DECIMAL_PLACES" not-null="false" unique="false" sql-type="INT"/>
</property>
</class>
</hibernate-mapping>
沒有財產 「小數位數」 一切工作正常。即使當我將屬性更改爲簡單數據類型int時。
有沒有人有線索是什麼問題?
你使用的是什麼版本的nhibernate? – Peter