I am using NHibernate 1.2.0 GA, writing my code in C# .Net 2.0 and storing the data in MS Sql Server 2005.
I am writing an enterprise level web application. I have just about all of the issues solved with the expection of a couple. They are basically the same so I will only post on as the solution to it will solve the other one. As a good like developer I have been writing unit tests to ensure that my code is doing what I expect it to do. I am not unit testing NHibernate as I know you do that well but I do unit test my mapping files and the code I am writing to make sure they are solid (enterprise level after all). The problem comes in one of the more crititcal mapping files. The crux of the matter is that it starts with one interface and then balloons out. I basically have 11 different object types in here. While I would like to pull them apart there are times when I need to load them into the same list and I didn't know another way of doing it except this way. I have some unit tests that are pretty basic. Create an object, save the object, load the object, update the object and then compare that the changes were as i expected them to be. I do this for each one.
The problem I am having is when I try to load the object. I am loading it with the generic base type (ICost interface) and then casting as as that is how I will use it in the application and I am getting an InvalidCastException error.
MAPPING FILE
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
<class name="DomainModel.Costs.ICost" table="Costs" schema="Costs" lazy="true">
<id name="Index" type="Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<column name="CostIndex" sql-type="uniqueidentifier" not-null="true" unique="true" index="PK_Cost"/>
<generator class="guid" />
</id>
<discriminator column="CostType" type="String" />
<property name="IsObsolete" type="Boolean">
<column name="IsObsolete" length="1" sql-type="bit" not-null="false"/>
</property>
<property name="Value" type="Decimal">
<column name="Value" sql-type="money" not-null="false"/>
</property>
<!-- DEALER CHARGE ITEM -->
<subclass name="DomainModel.Costs.Charges.DealerCharge, Company" discriminator-value="DealerChargeItem" proxy="DomainModel.Costs.ICharges, Company">
<property name="ChargeType" type="DomainModel.Costs.ChargeType, Company">
<column name="ChargeTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, RV, Dealer Charge)-->
<many-to-one name="Dealer" cascade="none" class="DomainModel.Organizations.DealershipLocation">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="false" />
</many-to-one>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="Description" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="IncludeInAPR" type="Boolean">
<column name="IncludeInAPR" sql-type="bit" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="Name" type="String">
<column name="Name" sql-type="varchar(100)" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="TaxBaseAddress" type="DomainModel.Tax.TaxBaseAddress, Company">
<column name="TaxBaseAddressIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<bag access="field" name="_taxStates" lazy="false" inverse="false" table="[XrefCostTaxableStates]" schema="Costs" cascade="all-delete-orphan">
<key column="CostIndex"/>
<many-to-many class="State" column="StateCode"/>
</bag>
</subclass>
<!-- LENDER CHARGE ITEM -->
<subclass name="DomainModel.Costs.Charges.LenderCharge, Company" discriminator-value="LenderChargeItem" proxy="DomainModel.Costs.ICharges, Company">
<property name="ChargeType" type="DomainModel.Costs.ChargeType, Company">
<column name="ChargeTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="Description" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<!-- COMMON (Dealer Charge, Lender Charge)-->
<property name="IncludeInAPR" type="Boolean">
<column name="IncludeInAPR" sql-type="bit" not-null="false" />
</property>
<many-to-one name="Lender" cascade="none" class="DomainModel.Lenders.Lender">
<column name="LenderIndex" sql-type="uniqueidentifier" not-null="false" />
</many-to-one>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="Name" type="String">
<column name="Name" sql-type="varchar(100)" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="TaxBaseAddress" type="DomainModel.Tax.TaxBaseAddress, Company">
<column name="TaxBaseAddressIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<bag access="field" name="_taxStates" lazy="false" inverse="false" table="[XrefCostTaxableStates]" schema="Costs" cascade="all-delete-orphan">
<key column="CostIndex"/>
<many-to-many class="State" column="StateCode"/>
</bag>
</subclass>
<!-- AFTERMARKET ITEM -->
<subclass name="DomainModel.Costs.Aftermarket.Product, Company" discriminator-value="AftermarketItem" proxy="DomainModel.Costs.IAftermarketProduct, Company">
<property name="Abbreviation" type="String">
<column name="Abbreviation" sql-type="varchar(10)" not-null="false" />
</property>
<property name="AftermarketType" type="DomainModel.Costs.AftermarketType, Company">
<column name="AftermarketTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, RV, Camper)-->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<property name="DealerCostType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerCostTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name="DealerPriceType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerPriceTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property access="field" name="_description" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="IncludeInAPR" type="Boolean">
<column name="IncludeInAPR" sql-type="bit" not-null="false" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name ="IsLocked" type="Boolean">
<column name="IsLocked" sql-type="bit" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="Name" type="String">
<column name="Name" sql-type="varchar(100)" not-null="false" />
</property>
<!-- COMMON (Aftermarket, RV, Dealer Charge, Camper)-->
<many-to-one name="Owner" cascade="none" class="DomainModel.Organizations.IOrganization">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<many-to-one name="Parent" cascade="none" class="DomainModel.Costs.ICost">
<column name="ParentIndex" sql-type="uniqueidentifier" not-null="false" />
</many-to-one>
<property name ="PlanMiles" type="Int32">
<column name="PlanMiles" sql-type="int" not-null="false" />
</property>
<property name ="PlanTerm" type="Int32">
<column name="PlanTerm" sql-type="int" not-null="false" />
</property>
<!-- PRICE is not mapped because it uses the global value-->
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="TaxBaseAddress" type="DomainModel.Tax.TaxBaseAddress, Company">
<column name="TaxBaseAddressIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<bag access="field" name="_taxStates" lazy="false" inverse="false" table="[XrefCostTaxableStates]" schema="Costs" cascade="all">
<key column="CostIndex"/>
<many-to-many class="State" column="StateCode"/>
</bag>
</subclass>
<!-- AFERMARKET ITEM (PROTECTION PLAN) -->
<subclass name="DomainModel.Costs.Aftermarket.ProtectionPlanProduct, Company" discriminator-value="ProtectionPlanItem" proxy="DomainModel.Costs.IAftermarketProduct, Company">
<property name="Abbreviation" type="String">
<column name="Abbreviation" sql-type="varchar(10)" not-null="false" />
</property>
<property name="AftermarketType" type="DomainModel.Costs.AftermarketType, Company">
<column name="AftermarketTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, RV, Camper)-->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<property name="DealerCostType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerCostTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name="DealerPriceType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerPriceTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property access="field" name="_description" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="Fabric" type="Boolean">
<column name="Fabric" sql-type="bit" not-null="false" />
</property>
<property name="IncludeInAPR" type="Boolean">
<column name="IncludeInAPR" sql-type="bit" not-null="false" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name ="IsLocked" type="Boolean">
<column name="IsLocked" sql-type="bit" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="Name" type="String">
<column name="Name" sql-type="varchar(100)" not-null="false" />
</property>
<!-- COMMON (Aftermarket, RV, Dealer Charge, Camper)-->
<many-to-one name="Owner" cascade="none" class="DomainModel.Organizations.IOrganization">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<many-to-one name="Parent" cascade="none" class="DomainModel.Costs.ICost">
<column name="ParentIndex" sql-type="uniqueidentifier" not-null="false" />
</many-to-one>
<property name="Paint" type="Boolean">
<column name="Paint" sql-type="bit" not-null="false" />
</property>
<property name ="PlanMiles" type="Int32">
<column name="PlanMiles" sql-type="int" not-null="false" />
</property>
<property name ="PlanTerm" type="Int32">
<column name="PlanTerm" sql-type="int" not-null="false" />
</property>
<!-- PRICE is not mapped because it uses the global value-->
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="TaxBaseAddress" type="DomainModel.Tax.TaxBaseAddress, Company">
<column name="TaxBaseAddressIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<bag access="field" name="_taxStates" lazy="false" inverse="false" table="[XrefCostTaxableStates]" schema="Costs" cascade="all">
<key column="CostIndex"/>
<many-to-many class="State" column="StateCode"/>
</bag>
<property name="VinylLeather" type="Boolean">
<column name="VinylLeather" sql-type="bit" not-null="false" />
</property>
</subclass>
<!-- AFERMARKET ITEM (SERVICE CONTRACT) -->
<subclass name="DomainModel.Costs.Aftermarket.ServiceContractProduct, Company" discriminator-value="ServiceContractItem" proxy="DomainModel.Costs.IAftermarketProduct, Company">
<property name="Abbreviation" type="String">
<column name="Abbreviation" sql-type="varchar(10)" not-null="false" />
</property>
<property name="AftermarketType" type="DomainModel.Costs.AftermarketType, Company">
<column name="AftermarketTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, RV, Camper) -->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<property name="DealerCostType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerCostTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name="DealerPriceType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerPriceTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge) -->
<property access="field" name="_description" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<property name="ExpirationDate" type="DateTime">
<column name="ExpireDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name ="ExpirationMiles" type="Int32">
<column name="ExpireMiles" sql-type="int" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge) -->
<property name="IncludeInAPR" type="Boolean">
<column name="IncludeInAPR" sql-type="bit" not-null="false" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name ="IsLocked" type="Boolean">
<column name="IsLocked" sql-type="bit" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge) -->
<property name="Name" type="String">
<column name="Name" sql-type="varchar(100)" not-null="false" />
</property>
<!-- COMMON (Aftermarket, RV, Dealer Charge, Camper)-->
<many-to-one name="Owner" cascade="none" class="DomainModel.Organizations.IOrganization">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<many-to-one name="Parent" cascade="none" class="DomainModel.Costs.ICost">
<column name="ParentIndex" sql-type="uniqueidentifier" not-null="false" />
</many-to-one>
<property name ="PlanMiles" type="Int32">
<column name="PlanMiles" sql-type="int" not-null="false" />
</property>
<property name ="PlanTerm" type="Int32">
<column name="PlanTerm" sql-type="int" not-null="false" />
</property>
<property name="ServiceContractType" type="DomainModel.Costs.ServiceContractType, Company">
<column name="ServiceContractTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- PRICE is not mapped because it uses the global value-->
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="TaxBaseAddress" type="DomainModel.Tax.TaxBaseAddress, Company">
<column name="TaxBaseAddressIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<bag access="field" name="_taxStates" lazy="false" inverse="false" table="[XrefCostTaxableStates]" schema="Costs" cascade="all">
<key column="CostIndex"/>
<many-to-many class="State" column="StateCode"/>
</bag>
</subclass>
<!-- AFERMARKET ITEM (TYRON PURCHASE AGREEMENT) -->
<subclass name="DomainModel.Costs.Aftermarket.TyronPurchaseAgreement, Company" discriminator-value="TyronPurchaseItem" proxy="DomainModel.Costs.IAftermarketProduct, Company">
<property name="Abbreviation" type="String">
<column name="Abbreviation" sql-type="varchar(10)" not-null="false" />
</property>
<property name="AftermarketType" type="DomainModel.Costs.AftermarketType, Company">
<column name="AftermarketTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, RV, Camper) -->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<property name="DealerCostType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerCostTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name="DealerPriceType" type="DomainModel.Costs.PriceType, Company">
<column name="DealerPriceTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge) -->
<property access="field" name="_description" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<property name ="DueBill" type="Boolean">
<column name="DueBill" sql-type="bit" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge) -->
<property name="IncludeInAPR" type="Boolean">
<column name="IncludeInAPR" sql-type="bit" not-null="false" />
</property>
<property name ="Installed" type="Boolean">
<column name="Installed" sql-type="bit" not-null="false" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryTypeIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<property name ="IsLocked" type="Boolean">
<column name="IsLocked" sql-type="bit" not-null="false" />
</property>
<property name ="ManualInVehicle" type="Boolean">
<column name="ManualInVehicle" sql-type="bit" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge) -->
<property name="Name" type="String">
<column name="Name" sql-type="varchar(100)" not-null="false" />
</property>
<!-- COMMON (Aftermarket, RV, Dealer Charge, Camper)-->
<many-to-one name="Owner" cascade="none" class="DomainModel.Organizations.IOrganization">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<many-to-one name="Parent" cascade="none" class="DomainModel.Costs.ICost">
<column name="ParentIndex" sql-type="uniqueidentifier" not-null="false" />
</many-to-one>
<property name ="PartNumber" type="String">
<column name="PartNumber" sql-type="varchar(20)" not-null="false" />
</property>
<property name ="PlanMiles" type="Int32">
<column name="PlanMiles" sql-type="int" not-null="false" />
</property>
<property name ="PlanTerm" type="Int32">
<column name="PlanTerm" sql-type="int" not-null="false" />
</property>
<property name ="RONumber" type="String">
<column name="RONumber" sql-type="varchar(20)" not-null="false" />
</property>
<!-- PRICE is not mapped because it uses the global value-->
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<property name="TaxBaseAddress" type="DomainModel.Tax.TaxBaseAddress, Company">
<column name="TaxBaseAddressIndex" length="8" sql-type="bigint" not-null="false"/>
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge)-->
<bag access="field" name="_taxStates" lazy="false" inverse="false" table="[XrefCostTaxableStates]" schema="Costs" cascade="all">
<key column="CostIndex"/>
<many-to-many class="State" column="StateCode"/>
</bag>
<property name ="UseAgreement" type="Boolean">
<column name="UseAgreement" sql-type="bit" not-null="false" />
</property>
</subclass>
<!-- INVENTORY BASE ITEM-->
<subclass name="DomainModel.Costs.Inventory.Inventory, Company" discriminator-value="InventoryItem" proxy="DomainModel.Costs.IInventory, Company">
<!-- COMMON (Aftermarket, Inventory)-->
<property name="AdditionalInformation" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<property name="BookPrice" type="Decimal">
<column name="BookPrice" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Inventory)-->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge, Inventory)-->
<many-to-one name="Dealer" cascade="save-update" class="DomainModel.Organizations.DealershipLocation">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<property name="Frieght" type="Decimal">
<column name="Frieght" sql-type="money" not-null="false" />
</property>
<property name="GrossWeight" type="Int32">
<column name="GrossWeight" sql-type="int" not-null="false" />
</property>
<property name="InStock" type="Boolean">
<column name="InStock" sql-type="bit" not-null="false"/>
</property>
<property name="InventoryState" type="DomainModel.Costs.InventoryState, Company">
<column name="InventoryState" sql-type="bigint" not-null="true" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryType" sql-type="bigint" not-null="true" />
</property>
<property name="InvoicePrice" type="Decimal">
<column name="Invoice" sql-type="money" not-null="false" />
</property>
<property access="field" name="_sold" type="Boolean">
<column name="IsSold" length="1" sql-type="bit" not-null="false"/>
</property>
<property access="field" name="_trade" type="Boolean">
<column name="IsTrade" length="1" sql-type="bit" not-null="false"/>
</property>
<property name="Length" type="Decimal">
<column name="Length" sql-type="money" not-null="false" />
</property>
<property name="LicensePlateNumber" type="String">
<column name="LicensePlateNumber" sql-type="varchar(20)" not-null="false" />
</property>
<many-to-one name="LicenseState" class="State" cascade="none">
<column name="LicenseState" sql-type="char(2)" not-null="false"/>
</many-to-one>
<property name="LicenseYear" type="Int32">
<column name="LicenseYear" sql-type="int" not-null="false" />
</property>
<property name="Make" type="String">
<column name="Make" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Model" type="String">
<column name="Model" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Odometer" type="Int32">
<column name="Odometer" sql-type="int" not-null="false" />
</property>
<property name="OdometerReadDate" type="DateTime">
<column name="OdometerReadDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="OdometerSticker" type="String">
<column name="OdometerSticker" sql-type="varchar(50)" not-null="false" />
</property>
<bag name="Options" inverse="false" lazy="false" cascade="all-delete-orphan" schema="Addons" table="XrefInventoryAddons">
<key column="CostIndex" />
<many-to-many class="DomainModel.Addons.IAddon, Company" column="AddonIndex"/>
</bag>
<!-- PRICE is not mapped because it uses the global value-->
<property name="ProductCode" type="String">
<column name="ProductCode" sql-type="varchar(20)" not-null="false" />
</property>
<property name="StickerNumber" type="String">
<column name="StickerNumber" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="StockNumber" type="String">
<column name="StockNumber" sql-type="varchar(100)" not-null="false" />
</property>
<property name="TitleNumber" type="String">
<column name="TitleNumber" sql-type="varchar(100)" not-null="false" />
</property>
<!-- VALUE is not mapped because it uses the price global value-->
<property name="VIN" type="String">
<column name="VIN" sql-type="varchar(20)" not-null="false" />
</property>
<property name="WarrentyEndDate" type="DateTime">
<column name="WarrentyEndDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="WarrentyStatus" type="DomainModel.Costs.WarrentyStatus, Company">
<column name="WarrentyStatusIndex" sql-type="bigint" not-null="false" />
</property>
<property name="Width" type="Decimal">
<column name="Width" sql-type="money" not-null="false"/>
</property>
<property name="Year" type="Int32">
<column name="Year" sql-type="int" not-null="false"/>
</property>
</subclass>
<!-- CAMPER ITEM-->
<subclass name="DomainModel.Costs.Inventory.Camper, Company" discriminator-value="CamperItem" proxy="DomainModel.Costs.Inventory.ICamper, Company">
<!-- INVENTORY BASE FIELDS START-->
<!-- COMMON (Aftermarket, Inventory)-->
<property name="AdditionalInformation" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<property name="BookPrice" type="Decimal">
<column name="BookPrice" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Inventory)-->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge, Inventory)-->
<many-to-one name="Dealer" cascade="save-update" class="DomainModel.Organizations.DealershipLocation">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<property name="Frieght" type="Decimal">
<column name="Frieght" sql-type="money" not-null="false" />
</property>
<property name="GrossWeight" type="Int32">
<column name="GrossWeight" sql-type="int" not-null="false" />
</property>
<property name="InStock" type="Boolean">
<column name="InStock" sql-type="bit" not-null="false"/>
</property>
<property name="InventoryState" type="DomainModel.Costs.InventoryState, Company">
<column name="InventoryState" sql-type="bigint" not-null="true" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryType" sql-type="bigint" not-null="true" />
</property>
<property name="InvoicePrice" type="Decimal">
<column name="Invoice" sql-type="money" not-null="false" />
</property>
<property access="field" name="_sold" type="Boolean">
<column name="IsSold" length="1" sql-type="bit" not-null="false"/>
</property>
<property access="field" name="_trade" type="Boolean">
<column name="IsTrade" length="1" sql-type="bit" not-null="false"/>
</property>
<property name="Length" type="Decimal">
<column name="Length" sql-type="money" not-null="false" />
</property>
<property name="LicensePlateNumber" type="String">
<column name="LicensePlateNumber" sql-type="varchar(20)" not-null="false" />
</property>
<many-to-one name="LicenseState" class="State" cascade="none">
<column name="LicenseState" sql-type="char(2)" not-null="false"/>
</many-to-one>
<property name="LicenseYear" type="Int32">
<column name="LicenseYear" sql-type="int" not-null="false" />
</property>
<property name="Make" type="String">
<column name="Make" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Model" type="String">
<column name="Model" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Odometer" type="Int32">
<column name="Odometer" sql-type="int" not-null="false" />
</property>
<property name="OdometerReadDate" type="DateTime">
<column name="OdometerReadDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="OdometerSticker" type="String">
<column name="OdometerSticker" sql-type="varchar(50)" not-null="false" />
</property>
<bag name="Options" inverse="false" lazy="false" cascade="all-delete-orphan" schema="Addons" table="XrefInventoryAddons">
<key column="CostIndex" />
<many-to-many class="DomainModel.Addons.IAddon, Company" column="AddonIndex"/>
</bag>
<!-- PRICE is not mapped because it uses the global value-->
<property name="ProductCode" type="String">
<column name="ProductCode" sql-type="varchar(20)" not-null="false" />
</property>
<property name="StickerNumber" type="String">
<column name="StickerNumber" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="StockNumber" type="String">
<column name="StockNumber" sql-type="varchar(100)" not-null="false" />
</property>
<property name="TitleNumber" type="String">
<column name="TitleNumber" sql-type="varchar(100)" not-null="false" />
</property>
<!-- VALUE is not mapped because it uses the price global value-->
<property name="VIN" type="String">
<column name="VIN" sql-type="varchar(20)" not-null="false" />
</property>
<property name="WarrentyEndDate" type="DateTime">
<column name="WarrentyEndDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="WarrentyStatus" type="DomainModel.Costs.WarrentyStatus, Company">
<column name="WarrentyStatusIndex" sql-type="bigint" not-null="false" />
</property>
<property name="Width" type="Decimal">
<column name="Width" sql-type="money" not-null="false"/>
</property>
<property name="Year" type="Int32">
<column name="Year" sql-type="int" not-null="false"/>
</property>
<!-- INVENTORY BASE FIELDS END-->
<property name="CamperType" type="DomainModel.Costs.CamperType, Company">
<column name="SubTypeIndex" sql-type="bigint" not-null="true" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="ExteriorColor" type="String">
<column name="ExteriorColor" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="InteriorColor" type="String">
<column name="InteriorColor" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="Style" type="String">
<column name="Style" sql-type="varchar(100)" not-null="false" />
</property>
</subclass>
<!-- RV ITEM-->
<subclass name="DomainModel.Costs.Inventory.RV, Company" discriminator-value="RVItem" proxy="DomainModel.Costs.IInventory, Company">
<!-- INVENTORY BASE FIELDS START-->
<!-- COMMON (Aftermarket, Inventory)-->
<property name="AdditionalInformation" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<property name="BookPrice" type="Decimal">
<column name="BookPrice" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Inventory)-->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge, Inventory)-->
<many-to-one name="Dealer" cascade="save-update" class="DomainModel.Organizations.DealershipLocation">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<property name="Frieght" type="Decimal">
<column name="Frieght" sql-type="money" not-null="false" />
</property>
<property name="GrossWeight" type="Int32">
<column name="GrossWeight" sql-type="int" not-null="false" />
</property>
<property name="InStock" type="Boolean">
<column name="InStock" sql-type="bit" not-null="false"/>
</property>
<property name="InventoryState" type="DomainModel.Costs.InventoryState, Company">
<column name="InventoryState" sql-type="bigint" not-null="true" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryType" sql-type="bigint" not-null="true" />
</property>
<property name="InvoicePrice" type="Decimal">
<column name="Invoice" sql-type="money" not-null="false" />
</property>
<property access="field" name="_sold" type="Boolean">
<column name="IsSold" length="1" sql-type="bit" not-null="false"/>
</property>
<property access="field" name="_trade" type="Boolean">
<column name="IsTrade" length="1" sql-type="bit" not-null="false"/>
</property>
<property name="Length" type="Decimal">
<column name="Length" sql-type="money" not-null="false" />
</property>
<property name="LicensePlateNumber" type="String">
<column name="LicensePlateNumber" sql-type="varchar(20)" not-null="false" />
</property>
<many-to-one name="LicenseState" class="State" cascade="none">
<column name="LicenseState" sql-type="char(2)" not-null="false"/>
</many-to-one>
<property name="LicenseYear" type="Int32">
<column name="LicenseYear" sql-type="int" not-null="false" />
</property>
<property name="Make" type="String">
<column name="Make" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Model" type="String">
<column name="Model" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Odometer" type="Int32">
<column name="Odometer" sql-type="int" not-null="false" />
</property>
<property name="OdometerReadDate" type="DateTime">
<column name="OdometerReadDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="OdometerSticker" type="String">
<column name="OdometerSticker" sql-type="varchar(50)" not-null="false" />
</property>
<bag name="Options" inverse="false" lazy="false" cascade="all-delete-orphan" schema="Addons" table="XrefInventoryAddons">
<key column="CostIndex" />
<many-to-many class="DomainModel.Addons.IAddon, Company" column="AddonIndex"/>
</bag>
<!-- PRICE is not mapped because it uses the global value-->
<property name="ProductCode" type="String">
<column name="ProductCode" sql-type="varchar(20)" not-null="false" />
</property>
<property name="StickerNumber" type="String">
<column name="StickerNumber" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="StockNumber" type="String">
<column name="StockNumber" sql-type="varchar(100)" not-null="false" />
</property>
<property name="TitleNumber" type="String">
<column name="TitleNumber" sql-type="varchar(100)" not-null="false" />
</property>
<!-- VALUE is not mapped because it uses the price global value-->
<property name="VIN" type="String">
<column name="VIN" sql-type="varchar(20)" not-null="false" />
</property>
<property name="WarrentyEndDate" type="DateTime">
<column name="WarrentyEndDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="WarrentyStatus" type="DomainModel.Costs.WarrentyStatus, Company">
<column name="WarrentyStatusIndex" sql-type="bigint" not-null="false" />
</property>
<property name="Width" type="Decimal">
<column name="Width" sql-type="money" not-null="false"/>
</property>
<property name="Year" type="Int32">
<column name="Year" sql-type="int" not-null="false"/>
</property>
<!-- INVENTORY BASE FIELDS END-->
<!-- COMMON (RV, Camper)-->
<property name="Axles" type="Int32">
<column name="Axles" sql-type="int" not-null="false"/>
</property>
<property name="ChassisMake" type="String">
<column name="ChassisMake" sql-type="varchar(100)" not-null="false" />
</property>
<property name="ChassisModel" type="String">
<column name="ChassisModel" sql-type="varchar(100)" not-null="false" />
</property>
<property name="ChassisStockNumber" type="String">
<column name="ChassisStockNumber" sql-type="varchar(20)" not-null="false" />
</property>
<property name="ChassisYear" type="Int32">
<column name="ChassisYear" sql-type="int" not-null="false" />
</property>
<property name="EngineType" type="DomainModel.Costs.EngineType, Company">
<column name="EngineTypeIndex" sql-type="bigint" not-null="false" />
</property>
<property name="ExteriorColor" type="String">
<column name="ExteriorColor" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="InteriorColor" type="String">
<column name="InteriorColor" sql-type="varchar(20)" not-null="false" />
</property>
<property name="KeyNumber" type="String">
<column name="KeyNumber" sql-type="varchar(20)" not-null="false" />
</property>
<property name="NumberOfCylinders" type="Int32">
<column name="NumberOfCylinders" length="4" sql-type="int" not-null="false"/>
</property>
<property name="RVType" type="DomainModel.Costs.RVType, Company">
<column name="SubTypeIndex" sql-type="bigint" not-null="true" />
</property>
<property name="SerialNumber" type="String">
<column name="SerialNumber" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="Style" type="String">
<column name="Style" sql-type="varchar(100)" not-null="false" />
</property>
<property name="UnitVIN" type="String">
<column name="UnitVIN" sql-type="varchar(20)" not-null="false" />
</property>
</subclass>
<!-- TRAILER ITEM-->
<subclass name="DomainModel.Costs.Inventory.Trailer, Company" discriminator-value="TrailerItem" proxy="DomainModel.Costs.IInventory, Company">
<!-- INVENTORY BASE FIELDS START-->
<!-- COMMON (Aftermarket, Inventory)-->
<property name="AdditionalInformation" type="String">
<column name="Description" sql-type="text" not-null="false" />
</property>
<property name="BookPrice" type="Decimal">
<column name="BookPrice" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Inventory)-->
<property name="Cost" type="Decimal">
<column name="Cost" sql-type="money" not-null="false" />
</property>
<!-- COMMON (Aftermarket, Dealer Charge, Lender Charge, Inventory)-->
<many-to-one name="Dealer" cascade="save-update" class="DomainModel.Organizations.DealershipLocation">
<column name="OrganizationIndex" sql-type="uniqueidentifier" not-null="true" />
</many-to-one>
<property name="Frieght" type="Decimal">
<column name="Frieght" sql-type="money" not-null="false" />
</property>
<property name="GrossWeight" type="Int32">
<column name="GrossWeight" sql-type="int" not-null="false" />
</property>
<property name="InStock" type="Boolean">
<column name="InStock" sql-type="bit" not-null="false"/>
</property>
<property name="InventoryState" type="DomainModel.Costs.InventoryState, Company">
<column name="InventoryState" sql-type="bigint" not-null="true" />
</property>
<property name="InventoryType" type="DomainModel.Costs.InventoryType, Company">
<column name="InventoryType" sql-type="bigint" not-null="true" />
</property>
<property name="InvoicePrice" type="Decimal">
<column name="Invoice" sql-type="money" not-null="false" />
</property>
<property access="field" name="_sold" type="Boolean">
<column name="IsSold" length="1" sql-type="bit" not-null="false"/>
</property>
<property access="field" name="_trade" type="Boolean">
<column name="IsTrade" length="1" sql-type="bit" not-null="false"/>
</property>
<property name="Length" type="Decimal">
<column name="Length" sql-type="money" not-null="false" />
</property>
<property name="LicensePlateNumber" type="String">
<column name="LicensePlateNumber" sql-type="varchar(20)" not-null="false" />
</property>
<many-to-one name="LicenseState" class="State" cascade="none">
<column name="LicenseState" sql-type="char(2)" not-null="false"/>
</many-to-one>
<property name="LicenseYear" type="Int32">
<column name="LicenseYear" sql-type="int" not-null="false" />
</property>
<property name="Make" type="String">
<column name="Make" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Model" type="String">
<column name="Model" sql-type="varchar(100)" not-null="false" />
</property>
<property name="Odometer" type="Int32">
<column name="Odometer" sql-type="int" not-null="false" />
</property>
<property name="OdometerReadDate" type="DateTime">
<column name="OdometerReadDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="OdometerSticker" type="String">
<column name="OdometerSticker" sql-type="varchar(50)" not-null="false" />
</property>
<bag name="Options" inverse="false" lazy="false" cascade="all-delete-orphan" schema="Addons" table="XrefInventoryAddons">
<key column="CostIndex" />
<many-to-many class="DomainModel.Addons.IAddon, Company" column="AddonIndex"/>
</bag>
<!-- PRICE is not mapped because it uses the global value-->
<property name="ProductCode" type="String">
<column name="ProductCode" sql-type="varchar(20)" not-null="false" />
</property>
<property name="StickerNumber" type="String">
<column name="StickerNumber" sql-type="varchar(20)" not-null="false" />
</property>
<!-- COMMON (RV, Camper)-->
<property name="StockNumber" type="String">
<column name="StockNumber" sql-type="varchar(100)" not-null="false" />
</property>
<property name="TitleNumber" type="String">
<column name="TitleNumber" sql-type="varchar(100)" not-null="false" />
</property>
<!-- VALUE is not mapped because it uses the price global value-->
<property name="VIN" type="String">
<column name="VIN" sql-type="varchar(20)" not-null="false" />
</property>
<property name="WarrentyEndDate" type="DateTime">
<column name="WarrentyEndDate" sql-type="smalldatetime" not-null="false" />
</property>
<property name="WarrentyStatus" type="DomainModel.Costs.WarrentyStatus, Company">
<column name="WarrentyStatusIndex" sql-type="bigint" not-null="false" />
</property>
<property name="Width" type="Decimal">
<column name="Width" sql-type="money" not-null="false"/>
</property>
<property name="Year" type="Int32">
<column name="Year" sql-type="int" not-null="false"/>
</property>
<!-- INVENTORY BASE FIELDS END-->
<property name="Axles" type="Int32">
<column name="Axles" sql-type="int" not-null="false"/>
</property>
<property name="TrailerType" type="DomainModel.Costs.TrailerType, Company">
<column name="SubTypeIndex" sql-type="bigint" not-null="true" />
</property>
</subclass>
<!-- INSURANCE POLICY ITEM-->
<subclass name="DomainModel.Costs.Insurance.InsurancePolicy, Company" discriminator-value="PolicyItem">
<many-to-one name="Agent" cascade="all-delete-orphan" class="DomainModel.Person, Company">
<column name="PersonIndex" sql-type="uniqueidentifier" not-null="false" />
</many-to-one>
<many-to-one name="Company" cascade="all-delete-orphan" class="DomainModel.Costs.Insurance.InsuranceCompany, Company">
<column name="InsuranceCompanyIndex" sql-type="bigint" not-null="false" length="8" />
</many-to-one>
<property name="CoverageAmount" type="Decimal">
<column name="CoverageAmount" sql-type="money" not-null="false"/>
</property>
<property name="Deductable" type="Decimal">
<column name="Deductable" sql-type="money" not-null="false"/>
</property>
<property name="EffectiveDate" type="DateTime">
<column name="EffectiveDate" sql-type="smalldatatime" not-null="false" />
</property>
<property name="PolicyNumber" type="String">
<column name="PolicyNumber" sql-type="varchar(100)" not-null="false" />
</property>
<property name="PolicyType" type="DomainModel.Costs.PolicyType, Company">
<column name="PolicyTypeIndex" length="8" sql-type="bigint" not-null="true"/>
</property>
</subclass>
</class>
</hibernate-mapping>
ERROR
[code]
UnitTests.Database.DomainModel.Costs.Inventory.CamperTest.Save:
System.InvalidCastException : Unable to cast object of type 'ProxyInterfaceSystemSystemObjec