Book Image

Learning NHibernate 4

Book Image

Learning NHibernate 4

Overview of this book

Table of Contents (18 chapters)
Learning NHibernate 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Order of operations


When you save an instance of a complex entity such as Employee which may have associations to several other entities, NHibernate has to do a lot of work to figure out how to insert/update/delete particular database records. It is important to not only generate correct set of SQL statements to get the work done, but it is even more important to fire these SQL statements in right order. With complex database table structures with lot of foreign key associations, it may be daunting to figure out right order of running a set of SQL statements. NHibernate makes the job easy for us by using the following order to ensure that SQL statements always go in right order:

  1. All entity insertions in the same order they were passed into the Save method of session.

  2. All entity updates.

  3. All collection deletions.

  4. All collection element deletions, updates, and insertions.

  5. All collection insertions.

  6. All entity deletions in the same order they were passed into the Delete method of session.

You do not...