concept object identity in category .net

appears as: object identity, object identity
NHibernate in Action

This is an excerpt from Manning's book NHibernate in Action.

The identity of a database row is commonly expressed as the primary key value. As you’ll see in section 3.5, .NET object identity isn’t naturally equivalent to the primary key value. With relational databases, it’s recommended that you use a surrogate key—a primary key column with no meaning to the user. But .NET objects have an intrinsic identity, which is based either on their memory location or on a user-defined convention (by using the implementation of the Equals() method).

You’ll then define mapping metadata to tell NHibernate how these classes and their properties relate to database tables and columns. We covered the basis of this step in chapter 2. In this chapter, we give an in-depth presentation of the mapping techniques for fine-grained classes, object identity, inheritance, and associations. This chapter therefore provides the beginnings of a solution to the first generic problems of ORM listed in section 1.3.1. For example, how do you map fine-grained objects to simple tables? Or how do you map inheritance hierarchies to tables?

3.5. Understanding object identity

It’s vital to understand the difference between object identity and object equality before we discuss terms like database identity and how NHibernate manages identity. You need these concepts if you want to finish mapping the CaveatEmptor persistent classes and their associations with NHibernate.