I'm mapping a ProductCategory tree using Fluent NHibernate and everything was going fine until I tried to walk the tree that is returned from the database to ensure it's saving and retreiving appropriately.
Here's how I'm testing:
- Instantiate 4 categories: Beverages, Beer, Light Beer, and Dark Beer
- Add Beer to Beverages, then Light Beer and Dark Beer to Beer.
- Save Beverages (cascade is set to AllDeleteOrphan)
- Flush the session, which persists the entire tree
- Evict each of the ProductCategories from the session
- Load Beverages from the database
- Check that the loaded object (fromDB) is EqualTo but not SameAs Beverages.
- Check that fromDB has only one child ProductCategory
- Check that the only child in fromDB is EqualTo but not SameAs Beer
The test fails because the child is the SameAs Beer. Which means that it's not actually loading the object from the database, because it's still in the NHibernate session somewhere.
Any insight will be much appreciated.
Edit: In response to Sean's comments below. I am using an in memory SQLite database, so as soon as the session/connections are closed the database is blown away.