>From the documentation on ISession.GetSession: Starts a new Session with the given entity mode in effect. This secondary Session inherits the connection, transaction, and other context information from the primary Session. It doesn't need to be flushed or closed by the developer.
I'm not an expert on the internals, but basically you need it when manipulating other persistent instances from places like an event listener (you can't happily call @event.Session.Save). Operations done on the secondary session keep transactional consistence with the rest of the session (something that would NOT happen when opening a new session from the SessionFactory) Diego On Tue, Mar 9, 2010 at 20:34, Ajai Shankar <[email protected]> wrote: > Hi Diego > > > > Most event listeners just use a child session... > > @event.Session.GetSession(EntityMode.Poco) > > What is the significance of using a child session? > > Ajai > > > On Tue, Mar 9, 2010 at 4:52 PM, nicklang <[email protected]> wrote: > >> Thanks Diego... You are right. Actually I now realize that my >> problems lie in the fact that I have no idea what I am doing, >> regarding the sessions. >> >> I'm going to inform myself much better before I ask another question >> and waste everyone's time! >> >> On Mar 9, 3:18 pm, Diego Mijelshon <[email protected]> wrote: >> > Are you really, really sure that you want a new session? >> > Most event listeners just use a child session... >> > @event.Session.GetSession(EntityMode.Poco) >> > >> > In any case, if you post the actual message and stacktrace of the error >> we >> > might be able to help you better. >> > >> > Diego >> > >> > >> > >> > On Tue, Mar 9, 2010 at 10:53, nicklang <[email protected]> wrote: >> > > Hi, >> > >> > > In IPreUpdateEventListener.OnPreUpdate() I'm trying to get a new >> > > session like this: >> > >> > > public bool OnPreUpdate(PreUpdateEvent @event) >> > > { >> > > ISession s = @event.Session.SessionFactory.OpenSession(); >> > >> > > Webpage p = new Webpage(); >> > > p.Name = "test"; >> > >> > > s.Save(p); >> > > s.Flush(); >> > >> > > return true; >> > > } >> > >> > > Is this the right way to go about this? I keep getting errors about >> > > missing tables when I try to Save() my new entity. >> > >> > > Thanks for any insight you may have! >> > >> > > -- >> > > 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. >> >> -- >> 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. >> >> > -- > 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. > -- 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.
