The mapping below works for my product - supplier relationship in that
it lazy loads a supplier object when I query the IList property of a
specific product object. But I can't figure out is why the lazy
loading does a query on the Suppliers table using the product ID
instead of the FK (SupplierID)

for example: right now product.suppliers(0).id = 1 same as the product
id instead of 22 as it shows up in northwind (supplierid = 22)

<?xml version="1.0" encoding="utf-8" ?>
  <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="SampleApplication.Library.Entity.Product,
SampleApplication.Library" table="Products">
    <id name="ID" column="ID" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="ProductName" column="ProductName" type="string"
not-null="false" />
    <property name="QuantityPerUnit" column="QuantityPerUnit"
type="string" not-null="false" />
    <property name="UnitPrice" column="UnitPrice" type="decimal" not-
null="false" />
    <property name="UnitsInStock" column="UnitsInStock" type="Int32"
not-null="false" />
    <property name="UnitsOnOrder" column="UnitsOnOrder" type="Int32"
not-null="false" />
    <property name="ReorderLevel" column="ReorderLevel" type="Int32"
not-null="false" />
    <property name="Discontinued" column="Discontinued" type="boolean"
not-null="false" />
    <bag name="Suppliers" generic="true" lazy="true" inverse="true">
      <key column="ID" />
      <one-to-many class="SampleApplication.Library.Entity.Supplier,
SampleApplication.Library"/>
    </bag>
  </class>
</hibernate-mapping>

Keep in mind that database PK for both Products and Suppliers SQL
tables are ID (not ProductID / SupplierID as they are w/ the default
Northwind database)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to