The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

Last post 09-25-2008, 11:59 AM by Mike.Griffin. 8 replies.
Sort Posts: Previous Next
  •  10-17-2007, 12:46 PM 5894

    During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    I've just discovered a save issue that is causing Foreign key reference errors. It is very simple to duplicate.

    1. Create a new entity in a parent collection.
    2. Create a child entity from the parent entities child collection.
    3. Call Save on the parent collection.
    4. Cause an error in the child collection save process. This causes the transaction to rollback.
    5. Call Save on the parent collection again. When you try to save a second time, the parent entity will not be inserted. Its status is set to Unchanged.

    Norm

     

  •  10-17-2007, 1:04 PM 5895 in reply to 5894

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    Yes, currently this is "as designed" but it doesn't mean that it will remain this way. What happens is as things save successfully, children for instance, they call AcceptChanges() and so on down the line. If somewhere along the hierarchy something fails, the transaction is rolled back which is good, but children can be left in a state which indicates that no data has changed (because AcceptChanges was called on them). What really needs to happen is that the top most parent upon a successful call to save needs to walk all of the children again to call Accept Changes, this isn't coming until ES2008 however. We can make it work as it should, but not in this release cycle, and our next big cylce is ES008.

    Probably, what we'll do is after each successful call to save during a transaction, each object will add itself to the transactions "AcceptChangesList" (which doesn't exist yet), then when the final scope.Complete() is called the esTransactionScope can call AcceptChanges on all of them. I know this isn't the answer you wanted. Let me talk to the team about this tomorrow night during our weekly team meeting.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  10-18-2007, 6:05 AM 5908 in reply to 5895

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    When will ES2008 be available? Is there any work around?

  •  08-13-2008, 7:51 AM 10724 in reply to 5895

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    Mike,

     I've recently upgraded to ES2008 and this issue is still present. Our release date is still in the far future, but this issue would be a show stopper.

     Thanks,

     Norm

  •  08-21-2008, 5:00 AM 10863 in reply to 10724

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    We are looking at this bug, it's a non-trivial fix for sure but our plan is too have this in our next maintenance release.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  09-25-2008, 10:35 AM 11642 in reply to 10724

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    I'm evaluating ES2008 and I can say it is a great product but I stuck with this same problem and alas there is no clone method.  This issue stops me from purchasing ES2008.
  •  09-25-2008, 10:46 AM 11643 in reply to 11642

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    So you're telling us it's time to add a Clone() method right Wink

    Okay, we will get this in ES2009, however, currently, when editing a single entity you can call BeginEdit() and then CancelEdit() to roll back any edits or EndEdit to make them the current data. Are you looking for a big hierarchical clone method that clones a hierarchical tree? Hopefully you just want a clone method on a single entity or a collection, but not a hierarchical tree.
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  09-25-2008, 11:08 AM 11644 in reply to 11643

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    The big one of course because to resolve this "saving child error" i need to preserve the rowstate from original entity and all its child.  Then i will call the save method on the cloned entity.
  •  09-25-2008, 11:59 AM 11645 in reply to 11644

    Re: During an add, if the child colleciton fails, the parent entity resets its status from Add to Unchanged.

    Acutally, we should have the entire hierarchical save / rollback fix in ES2009, we had it working in the last ES2008 except for one thing, ADO.NET is stupid. You can set the DataAdapter.AcceptChangesDuringUpdate property to false and it just doesn't work, it does accept the changes no matter what you set it to. So, it was changing the state of things on us even during failed update, really ticked me off honestly.

    So, in ES2009 will will no longer Save through Adapters but directly through commands, which is actually going ot better in some ways, had we not been so pressed for time I could have pulled it off, however, it meant a big pass through all of our providers (all 10 of them including the CF versions) and changing the Save logic. It will probably one take a week to make the changes but we couldn't get that in our last ES2008.

    Our goal is to have our ES2009 beta out by the end of this year with changes in the architecture, we haven't put this list together yet but will publish it soon.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML