Hello - I'm stuck in a big way and am wondering if someone can help me.
I have a clsOrder object which relats many-to-one with a clsCustomer object.
When I make changes to the clsOrder object, save it and then flush the session, I get an
Quote:
'iCustID_' appears more than once in the result column list' error.
I can't for the life of me figure out what's going on... and don't even know how to bypass NH doing the save so that I can do it manually.
Any help with this would be greatly appreciated as I'm now well and truly committed to using NH in my app - there's no going back.
Thanks very much in advance, There's another objects that touches the clsOrder class... (I've included clsItem's map). If it's not obvious what's going on, I'll try and dig out the other classes hbm files.
Cheers,
Damien Sawyer
Quote:
The Error
-------------------
2005-07-22 17:09:42,869 [3076] ERROR NHibernate.ADOException [] <> - could not synchronize database state with session
Exception: System.Data.SqlClient.SqlException
Message: Column name 'iCustID_' appears more than once in the result column list.
Source: .Net SqlClient Data Provider
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Boolean[] includeProperty, Object oldVersion, Object obj, SqlString sqlUpdateString, ISessionImplementor session)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledUpdate.Execute()
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
----------------------
Violating SQL String generated by NH
Code:
exec sp_executesql N'UPDATE tblOrders SET cLITM = @p0, iQtyCommit = @p1, iCustID_ = @p2, dRequestDate = @p3, cDataTypeID = @p4, cCustOrderNo = @p5, dPickDate = @p6, cMCU = @p7, iCustID_ = @p8, cCommitStatus = @p9, iQtyOrdered = @p10, nLNID = @p11, nDOCO = @p12, cMCUExt = @p13 WHERE iOrderID = @p14', N'@p0 nvarchar(4000),@p1 int,@p2 int,@p3 datetime,@p4 nvarchar(4000),@p5 nvarchar(4000),@p6 datetime,@p7 nvarchar(4000),@p8 int,@p9 nvarchar(4000),@p10 int,@p11 int,@p12 int,@p13 nvarchar(4000),@p14 int', @p0 = N'738522', @p1 = 240, @p2 = 145, @p3 = 'Jul 22 2005 12:00:00:000AM', @p4 = N'SO ', @p5 = N'94623878', @p6 = 'Jul 22 2005 12:00:00:000AM', @p7 = N'WES', @p8 = 145, @p9 = N'n', @p10 = 240, @p11 = 1, @p12 = 542511, @p13 = N'WES', @p14 = 3218
clsOrder.hbm.xml
------------------
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="OPWLibrary.clsOrder, OPWLibrary" table="tblOrders">
<id name="OrderID" column="iOrderID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="DataTypeID" column="cDataTypeID"/>
<property name="CustID" column="iCustID_"/>
<property name="CustOrderNumber" column="cCustOrderNo"/>
<property name="QtyOrdered" column="iQtyOrdered"/>
<property name="QtyCommitted" column="iQtyCommit"/>
<property name="CommitStatus" column="cCommitStatus"/>
<property name="RequestDate" column="dRequestDate"/>
<property name="PickDate" column="dPickDate"/>
<property name="DOCO" column="nDOCO"/>
<property name="LNID" column="nLNID"/>
<property name="_mCU" access="field" column="cMCU"/>
<property name="_mCUext" access="field" column="cMCUExt"/>
<!--<many-to-one name="Mcu" access="field" column="cMCU" not-null="true"/>-->
<!--<many-to-one name="McuExtended" access="field" column="cMCUExt" not-null="true" />-->
<many-to-one name="Item" access="field" column="cLITM" not-null="true"/>
<many-to-one name="Customer" access="field" column="iCustID_" not-null="true"/>
</class>
</hibernate-mapping>
clsCustomer.hbm.xml
----------------------
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="OPWLibrary.clsCustomer, OPWLibrary" table="tblCustomers">
<id name="_custID" access="field" column="iCustID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="_addressBookCode" access="field" column="nAddressBookCode"/>
<property name="_majorCode" access="field" column="cMajorCode"/>
<property name="_name" access="field" column="cName"/>
<property name="_berriSite" access="field" column="bBerriSite"/>
<bag name="_orders_NH" access="field" inverse="true" lazy="true">
<key column="iCustID"/>
<one-to-many class="OPWLibrary.clsOrder,OPWLibrary"/>
</bag>
<bag name="_dCs_NH" access="field" table ="tblCustomer_DC_Join" lazy="true">
<key column="iCustID"/>
<many-to-many class ="OPWLibrary.clsDC, OPWLibrary" column="iDCID"/>
</bag>
</class>
</hibernate-mapping>
clsItem.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="OPWLibrary.clsItem, OPWLibrary" table="tblItems">
<id name="Litm" column="cLITM" unsaved-value="0" length="6" type="string">
<generator class="assigned" />
</id>
<property name="Description" column="cDescription"/>
<property name="Chilled" column="bChilled"/>
<property name="ShelfLifeDays" column="iShelfLifeDays"/>
<bag name="_ordersNH" access="field" inverse="true" lazy="true">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.clsOrder,OPWLibrary"/>
</bag>
<set name="_sOHs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='SOH'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_SOH,OPWLibrary"/>
</set>
<set name="_sOHHs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='SOHH'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_SOHH,OPWLibrary"/>
</set>
<set name="_pOs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='PO'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_PO,OPWLibrary"/>
</set>
<set name="_wOs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='WO'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_WO,OPWLibrary"/>
</set>
<set name="_wPs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='WP'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_WP,OPWLibrary"/>
</set>
<set name="_sSTLs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='SSTL'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_SSTL,OPWLibrary"/>
</set>
<set name="_fCSTs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='FCST'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_FCST,OPWLibrary"/>
</set>
<set name="_sOs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='SO'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_SO,OPWLibrary"/>
</set>
<set name="_sTs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='ST'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_ST,OPWLibrary"/>
</set>
<set name="_sXs_NH" access="field" inverse="true" lazy="true" where="cDataTypeID='SX'">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_SX,OPWLibrary"/>
</set>
<set name="_gENERICs_NH" access="field" inverse="true" lazy="true">
<key column="cLITM"/>
<one-to-many class="OPWLibrary.CDT.clsCDT_Generic,OPWLibrary"/>
</set>
<!-- <bag name="_branchesNH" access="field" inverse="true" table ="tblCoreData" lazy="true">
<key column="cLITM"/>
<many-to-many class ="OPWLibrary.clsBranch, OPWLibrary" column="cMCU"/>
</bag>
-->
</class>
</hibernate-mapping>