Thanks, I do not fully understand the mechanism of the bags. Could
somebody shortly explain me this.

Lets say I retrieved Entities from a Database. All collections are
initialized correctly. Now I got a transient entity lets say
EntityA entityA = new EntityA();
entityA.PropEntityB = someEntityB;
If I do a session.Save(entityA) I have persisted it and NH knows about
entityA having a property called PropEntityB of Type EntityB. Why
isn't the collection updated automatically? It's clear that I want to
have the persistent entityA in the collection EntityB.EntityAList?

Thanks for your feedback

antoschka

On 3 Okt., 16:33, Paul Batum <[EMAIL PROTECTED]> wrote:
> The typical approach would be:
>
> class EntityA
> {
>   public void AddEntityB(Entity b)
>   {
>     this.EntityBList.Add(b);
>     b.EntityA = this;
>   }
>
> }
>
> I believe many people use this approach or something similar.
>
> On Oct 2, 7:26 pm,antoschka<[EMAIL PROTECTED]> wrote:
>
> > @ Fabio: So how would you approach the problem?
>
> > On 2 Okt., 13:58, "Fabio Maulo" <[EMAIL PROTECTED]> wrote:
>
> > > NH work as your DAL and don't play in your logical tier.
>
> > > 2008/10/2antoschka<[EMAIL PROTECTED]>
>
> > > > Hi,
>
> > > > I use one-to-many foreign keys in my entities. e.g. EntityA & EntityB
> > > > - EntityB has a Property which references EntityA
> > > > "<many-to-one name="EntityA " cascade="none" column="EntityA " not-
> > > > null="true" />"
>
> > > > - EntityA has a inverse bag which contains all EntityBs referencing to
> > > > EntityA
> > > > "<bag name="FkEntityB" inverse="true" lazy="true" cascade="all">
> > > >      <key column="EntityA " />
> > > >      <one-to-many class="[class], [assembly]" />
> > > >    </bag>
>
> > > > The whole thing works fine. The only problem I have is when I add a
> > > > transient new EntityB which references EntityA, hhe bag will not be
> > > > updated and I have to do it manually, by adding EntityB to the bag-
> > > > Collection.
>
> > > > How can this be done automatiaclly without making the new EntityB
> > > > persistent?
>
> > > > Tahnska in advance for your helpantoschka
>
> > > --
> > > 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