I've tried mapping one end as inverse, it still results in the
collection being loaded. To be clear, I want to add to the collection
*without loading it* as the collection is large. The only way I have
found that works is to introduce the mapping table as a class in the
model, making both ends of the many-to-many inverse and explicitly
saving the mapping table class.

This is an ugly hack that I thought experienced NHibernate users might
have a solution for.

On Feb 23, 12:49 pm, Fabio Maulo <[email protected]> wrote:
> http://nhforge.org/doc/nh/en/index.html#collections-bidirectional
>
> 2010/2/23 Jonathan Curtis <[email protected]>
>
>
>
> > Here are my mappings (which do not work):
>
> > EntityOne:
>
> > <bag cascade="all" name="EntityTwos" table="EntityOneToEntityTwo">
> >    <key>
> >        <column name="EntityOneId" />
> >    </key>
> >    <many-to-many class="NHibernateTest.EntityTwo, NHibernateTest,
> > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
> >        <column name="EntityTwoId" />
> >    </many-to-many>
> > </bag>
>
> > EntityTwo:
>
> > <bag cascade="all" name="EntityOnes" table="EntityOneToEntityTwo">
> >    <key>
> >        <column name="EntityTwoId" />
> >    </key>
> >    <many-to-many class="NHibernateTest.EntityOne, NHibernateTest,
> > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
> >        <column name="EntityOneId" />
> >    </many-to-many>
> > </bag>
>
> > Is this enough information?
>
> > On Feb 23, 3:06 am, Fabio Maulo <[email protected]> wrote:
> > > I have a problem doing this
> > > myEntity.OtherStuff.Remove(myOtherStuff)
> > > I don't like NH behaviour when I execute that code.
> > > Can you help me ?
>
> > > 2010/2/22 Jonathan Curtis <[email protected]>
>
> > > > I don't see how it is an abstract problem, I'm not doing anything
> > > > special. I'm just asking what mappings I should use that will enable
> > > > me to add to a many-to-many collection without that collection being
> > > > loaded:
>
> > > > myEntity.OtherEntities.Add(myOtherEntity);
>
> > > > It seems like this should be a common scenario. I appreciate the help.
> > > > I've tried various mapping, but all load up the collection. Is this
> > > > possible?
>
> > > > On Feb 22, 11:38 pm, John Davidson <[email protected]> wrote:
> > > > > Fabiois saying that dealing with an abstract problem is not going to
> > find
> > > > a
> > > > > resolution, either positive or negative. If you have a proff-of
> > concept
> > > > show
> > > > > the mappings used to the group, so that they can better help you.
>
> > > > > John Davidson
>
> > > > > On Mon, Feb 22, 2010 at 6:32 PM, Jonathan Curtis <
> > > > [email protected]
>
> > > > > > wrote:
> > > > > > Can you elaborate?
>
> > > > > > On Feb 22, 10:59 pm, Fabio Maulo <[email protected]> wrote:
> > > > > > > mappings
>
> > > > > > > 2010/2/22 Jonathan Curtis <[email protected]>
>
> > > > > > > > We have a entity with a many-to-many collection mapped as a
> > lazy
> > > > > > > > loaded bag. When we load up the entity, the collection is not
> > > > loaded -
> > > > > > > > great. Now we want to add a new entity to that collection. As
> > soon
> > > > as
> > > > > > > > we do this, the collection is loaded up.
>
> > > > > > > > How do we add the new entity without loading up the whole
> > > > collection
> > > > > > > > (the collection is large)?
>
> > > > > > > > --
> > > > > > > > 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]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > <nhusers%[email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > > > <nhusers%[email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > <nhusers%[email protected]<nhusers%[email protected]>
> > <nhusers%[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]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > <nhusers%[email protected]<nhusers%[email protected]>
> > <nhusers%[email protected]<nhusers%[email protected]>
>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > > --
> > > > 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]>
> > <nhusers%[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]<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