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

Chapter 5. Let's Store Some Data into the Database

Almost every unit test that we looked at in Chapter 3, Let's Tell NHibernate About Our Database involved saving entities into database. Back then we had used very simple code to save entities into in-memory database. We had said that we would look at that particular piece of code in detail in one of the upcoming chapters. This is the chapter where we would learn more about what that piece of code did for us.

We will begin this chapter with three important concepts that we must understand before we start interacting with NHibernate API that lets us store data into database. The first concept is entity states. NHibernate uses entity states to determine what action needs to be taken when entity is presented to NHibernate API. Second concept is transactions. NHibernate offers an abstraction over database's native transaction in the form of its transaction API. Understanding transactions is very fundamental to understanding how NHibernate synchronizes...