If something is not working as you are expecting probably you wrote wrong
mappings.

2009/8/4 Imajeep <[email protected]>

>
> Can I delete an object from a persistent collection, then call
> ISession.Update() to sync the deletion back to the database?
>
> I am building a simple demo project manager to help learn NHibernate.
> My object graph has Owners at the top; Owners have Projects, and
> Projects have Steps. I have written a unit test that does the
> following:
>
> First, it loads the Owner with a specified ID; the owner has two
> Projects. That works fine. Then it calls owner.Projects.RemoveAt(0) to
> remove the owner's first project. Once that is done, the test verifies
> that the owner has only one project. That works fine.
>
> Then the test calls ISession.Update() to update the owner object. I
> had expected Update() to sync the database to the change in the object
> graph, with the result that the deleted project's record would be
> removed from the database.
>
> Finally, the test closes the original session and open a new session.
> It then reloads the same owner and counts the number of projects. At
> this point the test fails, because the owner has the original two
> projects, instead of the expected one project. In other words, the
> deletion from the object graph was not persisted back to the database.
>
> I am not sure whether I am simply going about this the wrong way, or
> if I am doing it the right way but have something wrong in my mapping
> file. So that brings me to my question:
>
> Am I using the correct approach in deleting from the object graph,
> then updating to persist the change to the database? Or do I need to
> go about persisting this type of change some other way? Thanks for
> your help.
>
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to