NHibernate: What are children's sessions and why and when should I use them?

In comments to Ayende the blog of the audit in NHibernate there is mention of the need to use a subsidiary session : session.GetSession(EntityMode.Poco).

As far as I understand, it has something to do with the order of the SQL operation that session.Flush will run. (For example: if I wanted to perform some delete operation in the pre-insert event, but the session was already completed with the removal of operations, I will need some way to insert them.)

However, I did not find documentation about this function and behavior.

Questions:

  • Is my understanding of child sessions correct?

  • How and in which scenarios should I use them?

  • Are they recorded somewhere?

  • Can they be used to determine the "session" of a session?
    (For example: I open a master session in which some data will be stored, and then I create 2 child sessions from the main. I expect the two child areas to be separated, but will exchange objects from the master session cache. Is that the case? )

  • Are they first-class citizens at NHibernate, or are they just hacking support for some scripts with edge scripts?

Thanks in advance for any information.

+5
source share
1 answer

Stefando

NHibernate does not know about child sessions; you can reuse an existing one or open a new one.

For example, you will get an exception if you try to load the same object in two different sessions.

, , , preupdate preinsert , allready, , , .

, , auditlog. , ( ), .

0

All Articles