take care with SELECT-N+1 when you are going to query AddressOwner

On Tue, Oct 5, 2010 at 2:14 PM, David McClelland <[email protected]
> wrote:

> Fabio that works great - thanks!  Here's my mappings, just in case
> others want to see them - let me know if I messed anything up.
>
> In the User/Contact/Business mapping files:
>
>    <bag name="AddressOwners" access="field.camelcase-underscore"
> inverse="true" cascade="all-delete-orphan" where="AddressOwnerTypeId =
> 102">
>      <key column="OwnerId" />
>      <one-to-many class="AddressOwner" />
>    </bag>
>
>    NOTE:  102 is the AddressOwnerTypeId for a User, this is different
> in the Contact and Business as you will see below.
>
> In the AddressOwner mapping file:
>
>    <any name="Owner" id-type="System.Int32" meta-type="System.Int32"
> access="field.camelcase-underscore">
>      <meta-value value="102" class="User"/>
>      <meta-value value="104" class="Contact"/>
>      <meta-value value="106" class="Business"/>
>      <column name="AddressOwnerTypeId"/>
>      <column name="OwnerId"/>
>    </any>
>
> By the way - a "gotcha" that I ran into the first time I tried saving
> a User with a newly-added AddressOwner was the following error:
>
>    Invalid index 5 for this SqlParameterCollection with Count=5
>
> I by mistake had left a property mapping for the AddressOwnerTypeId
> column in the AddressOwner class, but I removed it because the <any>
> was taking care of that column for me and I didn't really need that
> property anyways.  If I had needed it, I guess I could have set its
> insert="false" and update="false" attributes like Tim Weaver did
> here:
> http://codeverity.com/timweaver/nhibernate-invalid-index-for-this-sqlparametercollection/
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
Fabio Maulo

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