I am mapping a ProductCategory tree through Fluent NHibernate and as long as I do not try to walk on that tree
- Instant 4 categories: Beverages, Beer, Light Beer, and Dark Beer
- Add beer to beverage, then light beer and dark beer to beer.
- Save Beverage (set to Cascade All Delayed Orphan)
- Flush the session, which
- Exclude each of the product categories from the session < / Li>
- Load beverages from the database
- Check that the Loaded Object (DDB) is equal, but not SameAs Beverage
- Check that DD Only one child is ProductCategory
- Check that the only child of DDB is equal, but not SameAs beer
The test fails because the child is Sam's beer. This means that it is not actually loading the object from the database, because it is still somewhere in the National Hibernate session.
Editing: I am using a SQLite database in memory in response to Shawn's comment, so as soon as the session / connection is closed The database goes away.
Just solved it, it was found that it was a copy and paste bug, PEBKAC.
I've added 4 statements that verify that objects are not in session:
responsibility This (session. Consistency (_beveragesCategory), is.False); Reveal it. That is included in this session (_BRC category), ISFFE); Notice. In that (session (_darkBeerCategory), ISFFl); Notice. That (session is in it (_Light beer category), flakesy);
When all of those (for the first time I participated) I tracked a close look at the code which was telling that the objects were different, and found that the accused were wrong.
was:
assurance. That (_beverageCategory.ChildCategories [0], is.Not.SameAs (_beerCategory));
should have been:
assurance. That (fromDB.ChildCategories [0], Is.Not.SameAs (_beerCategory));
Comments
Post a Comment