I've looked at hibernate forum and docs, at nhibernate forum and docs and I can't find a solution to this problem.
I have a mapping
Code:
<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="PerpetualInventory.Part, PerpetualInventory" table="PMA_TBL">   
   
      <!-- The table uses a the part only and part rev fields as a unique identifier -->
      <composite-id>
         <key-property name="PartOnly" column="PMA_PART_ONLY" access="field.pascalcase-m-underscore"/>
         <key-property name="PartRev" column="PMA_PART_REV" access="field.pascalcase-m-underscore"/>
      </composite-id>
            
      <!-- Map the table fields -->
      <property name="Desc" column="PMA_DESC" access="field.pascalcase-m-underscore"/>
      <property name="Desc_1" column="PMA_DESC_1" access="field.pascalcase-m-underscore"/>
      <property name="ProcurementCode" column="PMA_PROC_CODE" access="field.pascalcase-m-underscore"/>
      <property name="ABC" column="PMA_ABC_CODE" access="field.pascalcase-m-underscore"/>
      <property name="UOM" column="PMA_UOM" access="field.pascalcase-m-underscore"/>
      <property name="LastCheckDate" column="PMA_LAST_CHECK_DATE" access="field.pascalcase-m-underscore" not-null="false"/>
   
      <!--There is a one-to-many relationship between the Part and MRPOutput based upon the PartOnly
         and the PartRev-->      
      <bag name="MRPOutputs" inverse="true" access="field.pascalcase-m-underscore">
         <key>
            <column name="PMA_PART_ONLY" />
            <column name="PMA_PART_REV" /> 
         </key>
         <one-to-many class="PerpetualInventory.MRPOutput, PerpetualInventory"/>
      </bag>
         
      
      <!--There is a one-to-many relationship between the Part and Lot based upon the PartOnly
         and the PartRev-->
      <bag name="Lots" inverse="true" lazy="true" access="field.pascalcase-m-underscore">
         <key>
            <column name="PMA_PART_ONLY"/>
            <column name="PMA_PART_REV"/>
         </key>
         <one-to-many class="PerpetualInventory.Lot, PerpetualInventory"/>
      </bag>
      
   </class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="PerpetualInventory.MRPOutput, PerpetualInventory" table="SCF_TBL">   
   
      <id name="ID" column="SCF_UNIQUE" type="Int32" unsaved-value="0" access="field.pascalcase-m-underscore">
         <generator class="identity"/>
      </id>
         
      <property name="OrderDate" column="SCF_ORDER_DATE" type="DateTime" access="field.pascalcase-m-underscore"/>
            
      <many-to-one name="Part" class="PerpetualInventory.Part, PerpetualInventory" 
                              access="field.pascalcase-m-underscore"
                               not-null="false" cascade="none">
               <column name="SCF_PART_ONLY"  unique-key="PMA_PART_ONLY"/>
               <column name="SCF_PART_REV"   unique-key="PMA_PART_REV"/>  
      </many-to-one>
      
      
   </class>
</hibernate-mapping>
When I set the lazy attribute for the mapping for MRPOutputs to true it works fine, when I remove the lazy attribute (as shown above) I get a 'Probelm with find' error message.
The output shows:
Code:
4547 [3992] ERROR NHibernate.ADOException  - problem in find
Exception: System.Data.SqlClient.SqlException
Message: Invalid column name 'PMA_PART_ONLY'.
Source: .Net SqlClient Data Provider
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
   at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
   at NHibernate.Loader.Loader.DoFind(ISessionImplementor session, QueryParameters parameters, Object optionalObject, Object optionalID, PersistentCollection optionalCollection, Object optionalCollectionOwner, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoFindAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters parameters, Object optionalObject, Object optionalID, PersistentCollection optionalCollection, Object optionalCollectionOwner, Boolean returnProxies)
   at NHibernate.Loader.Loader.LoadCollection(ISessionImplementor session, Object id, IType type, Object owner, PersistentCollection collection)
   at NHibernate.Loader.OneToManyLoader.Initialize(Object id, PersistentCollection collection, Object owner, ISessionImplementor session)
   at NHibernate.Impl.SessionImpl.InitializeCollection(PersistentCollection collection, Boolean writing)
   at NHibernate.Collection.PersistentCollection.ForceInitialization()
   at NHibernate.Impl.SessionImpl.InitializeNonLazyCollections()
   at NHibernate.Loader.Loader.DoFindAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters parameters, Object optionalObject, Object optionalID, PersistentCollection optionalCollection, Object optionalCollectionOwner, Boolean returnProxies)
   at NHibernate.Loader.Loader.Find(ISessionImplementor session, QueryParameters parameters, Boolean returnProxies)
   at NHibernate.Loader.CriteriaLoader.List(ISessionImplementor session)
   at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)
I can't see what I'm doing wrong,
I get the same error if the MRPOutput.hbm.xml reads as below (unique-key attributes removed):
Code:
<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="PerpetualInventory.MRPOutput, PerpetualInventory" table="SCF_TBL">   
   
      <id name="ID" column="SCF_UNIQUE" type="Int32" unsaved-value="0" access="field.pascalcase-m-underscore">
         <generator class="identity"/>
      </id>
         
      <property name="OrderDate" column="SCF_ORDER_DATE" type="DateTime" access="field.pascalcase-m-underscore"/>
            
      <many-to-one name="Part" class="PerpetualInventory.Part, PerpetualInventory" 
                              access="field.pascalcase-m-underscore"
                               not-null="false" cascade="none">
               <column name="SCF_PART_ONLY" />
               <column name="SCF_PART_REV"  />  
      </many-to-one>
      
      
   </class>
</hibernate-mapping>
[quote][/quote]