Я сталкиваюсь с проблемами при сопоставлении группы свойств с элементом - в nhibernate.
<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"/>
It seems as saving works but when loading the vehicle property is null and the year property is 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"/>
Does someone have any idea why the loading does not work? Or an idea why creating the unique index is buggy with the second mapping?