Time for action – Causing a phantom update

In this exercise, we want to create a situation where NHibernate creates a phantom update. The cause of the phantom updates will be an inconsistency between the database table column and the respective property of the entity. In the database table, the column is defined as nullable, but the corresponding property of the entity is not nullable. We have to "cheat" and use some SQL bulk operation to prepare our data the way that the scenario is possible. Let's start now.

  1. Open Visual Studio and open the Chapter11 Samples solution.
  2. Add a new Console Application type project to the solution. Call the project PhantomUpdates.
  3. Add references to NHibernate, NHibernate.ByteCode.Castle, and FluentNHibernate to the project. ...

Get NHibernate 3 Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.