When I map a class which spans 2 tables in our database, I use the
following mapping:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="NHTest" namespace="NHTest.Model">
  <class name="EntityAndPrimaryAddress" table="[dbo].[Entity]"
optimistic-lock="version">
    <id name="EntityId" column="EntityId" >
      <generator class="identity" />
    </id>
    <version name="UpdateCounter" column="UpdateCounter" />
    <property name="CreatedBy" column="CreatedBy"  />
    <property name="CreatedDate" column="CreatedDate"  />
    <property name="ModifiedBy" column="ModifiedBy" />
    <property name="ModifiedDate" column="ModifiedDate" />
    <property name="Name" column="Name" type="AnsiString" />
    <join table="[dbo].[EntityAddress]" fetch="select">
        <key column="EntityId"/>
        <property name="Line1"/>
        <property name="Line2"/>
        <property name="City"/>
        <property name="State"/>
      <property name="PostalCode"/>
      <property name="IsPrimary"/>
    </join>
  </class>
</hibernate-mapping>

I would have expected the <join> element's fetch="select" to issue a
second SELECT statement, but I still get one SQL statement with an
INNER JOIN.

If I could make this be a LEFT JOIN that would be fine with me, or get
it to issue a second SELECT statement.  My goal is to be able to
handle the case where Entity table entries do not have a corresponding
entry in the EntityAddress table.  Is there a better way to do this?

Thanks,
David

-- 
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