1
我在使用nhibernate中的-element映射一组属性时遇到了问题。NHibernate <properties>
<class name="PlannedSalesInYear"
table="tblPlannedSalesInYear"
lazy="false" >
<id name="_businessId"
column="BusinessId"
access="field">
<generator class="assigned" />
</id>
<properties name="UIDX_PSPerVehicleAndYear"
optimistic-lock="true"
insert="true"
update="true"
unique="true">
<property name="_year"
access="field"
column="Year"/>
<many-to-one name="_vehicle"
access="field"
fetch="select"
column="VehicleId"
foreign-key="FK_VehicleOfPlannedSalesInYear"/>
</properties>
<property name="_plannedSales"
not-null="false"
access="field"
column="PlannedSales"/>
它似乎节省了工作,但装载车辆财产时,空和年属性为0
当改变映射,并避免它的工作-Tag。不幸的是,在这种情况下,唯一的索引不能像预期的那样工作(Sqlite)。
更改映射:
<class name="PlannedSalesInYear"
table="tblPlannedSalesInYear"
lazy="false" >
<id name="_businessId"
column="BusinessId"
access="field">
<generator class="assigned" />
</id>
<property name="_plannedSales"
not-null="false"
access="field"
column="PlannedSales"
/>
<property name="_year"
access="field"
unique-key="UIDX_PSPerVehicleAndYear"
column="Year"/>
<many-to-one name="_vehicle"
access="field"
fetch="select"
column="VehicleId"
unique-key="UIDX_PSPerVehicleAndYear"
foreign-key="FK_VehicleOfPlannedSalesInYear"/>
是否有人有任何想法,为什么加载不工作?或者,为什么创建唯一索引是第二次映射的错误?