Note that there are some explanatory texts on larger screens.

plurals
  1. POsimple joined-subclass example tries to update the identity column of the base table
    primarykey
    data
    text
    <p>I must be missing something very important in the concept to get this error so any help appreciated.</p> <p>I get ----> System.Data.SqlClient.SqlException : Cannot update identity column 'ProductID'.</p> <p>when i run this</p> <pre><code> var tblEvent = session.Load&lt;TblEvent&gt;(17); tblEvent.Code+= " - test update"; using (var tran = session.BeginTransaction()) { session.SaveOrUpdate(tblEvent); tran.Commit(); } </code></pre> <p>The load works correctly and i can inspect all the properties but the update fails.</p> <p>Heres the mapping file</p> <pre><code>&lt;hibernate-mapping namespace="Booking.BLL" assembly="Booking.BLL" xmlns="urn:nhibernate-mapping-2.2" &gt; &lt;class name="TblProduct" table="tblProduct" schema="dbo"&gt; &lt;id name="_productID" access="field" column="ProductID" type="Int32" &gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;property name="Active" type="Boolean" not-null="true" /&gt; &lt;property name="AllowBackOrder" type="Boolean" not-null="true" /&gt; &lt;property name="BuyY" type="Int32" precision="10" /&gt; &lt;property name="BuyYQty" type="Int32" precision="10" /&gt; &lt;property name="CategoryID" type="Int32" precision="10" /&gt; &lt;property name="Code" type="String" length="50" /&gt; &lt;property name="ColourID" type="Int32" precision="10" /&gt; &lt;property name="ColourNameOverride" type="String" length="250" /&gt; &lt;property name="Cost" type="Decimal" precision="10" not-null="true" /&gt; &lt;property name="CreatedBy" type="Int32" precision="10" /&gt; &lt;property name="CreatedDate" type="DateTime" /&gt; &lt;property name="CustomSort1" type="Int32" precision="10" /&gt; &lt;property name="CustomSort2" type="Int32" precision="10" /&gt; &lt;property name="CustomSort3" type="Int32" precision="10" /&gt; &lt;property name="DefaultImageID" type="Int32" precision="10" /&gt; &lt;property name="Depth" type="Decimal" precision="10" not-null="true" /&gt; &lt;property name="DispatchCategoryID" type="Int32" precision="10" /&gt; &lt;property name="DisplayIfNoStock" type="Boolean" not-null="true" /&gt; &lt;property name="GetXFree" type="Int32" precision="10" /&gt; &lt;property name="GetXPercentDiscount" type="Decimal" precision="6" /&gt; &lt;property name="Height" type="Decimal" precision="10" not-null="true" /&gt; &lt;property name="IsFavourite" type="Boolean" not-null="true" /&gt; &lt;property name="IsFeatured" type="Boolean" not-null="true" /&gt; &lt;property name="IsInSite" type="Int32" precision="10" /&gt; &lt;property name="IsSpecial" type="Boolean" not-null="true" /&gt; &lt;property name="Keywords" type="String" length="250" /&gt; &lt;property name="LongDescription" length="2147483647" /&gt; &lt;property name="LongDescription2" length="2147483647" /&gt; &lt;property name="LongDescription3" length="2147483647" /&gt; &lt;property name="ManufacturerID" type="Int32" precision="10" /&gt; &lt;property name="Name" type="String" length="250" not-null="true" /&gt; &lt;property name="NoStockMessage" type="String" length="250" /&gt; &lt;property name="OrderRanking" type="Int32" precision="10" /&gt; &lt;property name="ParentID" type="Int32" precision="10" /&gt; &lt;property name="Price" type="Decimal" precision="10" not-null="true" /&gt; &lt;property name="PriceMember" type="Decimal" precision="10" /&gt; &lt;property name="PriceRRP" type="Decimal" precision="10" /&gt; &lt;property name="PriceSpecial" type="Decimal" precision="10" /&gt; &lt;property name="PromotionID" type="Int32" precision="10" /&gt; &lt;property name="RefExt" type="String" length="250" /&gt; &lt;property name="SellBundledOnly" type="Boolean" /&gt; &lt;property name="Sex" type="Int32" precision="10" /&gt; &lt;property name="ShortDescription" type="String" length="500" not-null="true" /&gt; &lt;property name="Size" type="String" length="50" /&gt; &lt;property name="SizeID" type="Int32" precision="10" /&gt; &lt;property name="SizeNameOverride" type="String" length="250" /&gt; &lt;property name="SizeUnit" type="String" length="10" /&gt; &lt;property name="SpecialEnd" type="DateTime" /&gt; &lt;property name="SpecialStart" type="DateTime" /&gt; &lt;property name="Status" type="Boolean" not-null="true" /&gt; &lt;property name="Stock" type="Int32" precision="10" not-null="true" /&gt; &lt;property name="SupplierID" type="Int32" precision="10" /&gt; &lt;property name="TaxExempt" type="Boolean" not-null="true" /&gt; &lt;property name="UpdateBy" type="Int32" precision="10" /&gt; &lt;property name="UpdateDate" type="DateTime" /&gt; &lt;property name="WeightKG" type="Decimal" precision="10" not-null="true" /&gt; &lt;property name="Width" type="Decimal" precision="10" not-null="true" /&gt; &lt;many-to-one name="Parent" class="TblProduct" column="ProductID" not-null="true" /&gt; &lt;bag name="TblProducts" table="tblProduct" inverse="true"&gt; &lt;key column="ProductID" /&gt; &lt;one-to-many class="TblProduct" /&gt; &lt;/bag&gt; &lt;joined-subclass name="TblEvent" table="tblEvent"&gt; &lt;key column="EventID" /&gt; &lt;property name="AttachmentFileURL" type="String" length="200" /&gt; &lt;property name="GLAccountNo" type="String" length="20" /&gt; &lt;property name="MultiDayEvent" type="Boolean" not-null="true" /&gt; &lt;property name="PromotionActive" type="Boolean" not-null="true" /&gt; &lt;property name="RequiresLogin" type="Boolean" not-null="true" /&gt; &lt;property name="TopLevelCategoryID" type="Int32" precision="10" not-null="true" /&gt; &lt;property name="TotalAllocation" type="Int32" precision="10" not-null="true" /&gt; &lt;bag name="TblSessionTemplates" table="tblSessionTemplate" inverse="true"&gt; &lt;key column="EventID" /&gt; &lt;one-to-many class="TblSessionTemplate" /&gt; &lt;/bag&gt; &lt;bag name="TblSessions" table="tblSession" inverse="true"&gt; &lt;key column="EventID" /&gt; &lt;one-to-many class="TblSession" /&gt; &lt;/bag&gt; &lt;/joined-subclass&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload