New Posts New Posts RSS Feed: BUG - RejectChanges
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

BUG - RejectChanges

 Post Reply Post Reply
Author
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Topic: BUG - RejectChanges
    Posted: 20-Jun-2010 at 12:10pm
Hi,

I've found a bug in the RejectChanges method. RejectChanges does not return relation properties back to what they were.

Example:

License
    LicenseTypeId = 1
    LicenseType = LicenseType ('Type 1')

CHANGE LicenseType = 'Type 2'

License
    LicenseTypeId = 2
    LicenseType = LicenseType ('Type 2')

Now call RejectChanges() and it looks as follows:

License
    LicenseTypeId = 1
    LicenseType = LicenseType ('Type 2')



Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 20-Jun-2010 at 12:48pm
My temporary solution is to do the following:

    Public Property LicenseType2 As LicenseType
        Get
            Return Me.EntityManager.GetQuery(Of LicenseType).Where(Function(l) l.Id = Me.LicenseTypeId).FirstOrNullEntity()
        End Get
        Set(ByVal value As LicenseType)
            Me.LicenseTypeId = value.Id
        End Set
    End Property

Now I can bind to LicenseType2 and reject changes shows the correct value.
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 21-Jun-2010 at 1:47pm
Originally posted by smi-mark

Hi,I've found a bug in the RejectChanges method. RejectChanges does not return relation properties back to what they were.


I have duplicated this issue and entered a bug report.

All please note that RejectChanges() will NOT undo changes in related child entities; e.g., if you add Order y to Customer x, rejecting changes on Customer x will not remove the association between Order y and Customer x, because that change actually took place on the Order, not the Customer.

But in the case of changing a relation involving a parent, RejectChanges() should undo the change, since the foreign key lives on the child. For example, if you change the Customer associated with an Order, rejecting changes on the Order should undo the change in the relation. This is smi-mark's use case.

DevForce is undoing the foreign key value, but the relation is still returning the original parent. We'll get it fixed.

Edited by GregD - 21-Jun-2010 at 1:48pm
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 24-Jun-2010 at 3:49pm
Bug has been fixed. Fix will go out with the next DevForce 2010 release.
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2010 at 2:04pm
Thanks Greg. Is there an expected release date? We have a project going into production in just over a month, so I'd like to have this in before then!

Mark
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 28-Jun-2010 at 5:51pm
Hi Mark - We're currently scheduled to release in the last two weeks of July.
Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 02-Aug-2010 at 4:06pm
In DevForce 6.0.4
Rejecting changes for the entire EntityManager does not seem to restore a parent's relationship to the deleted child.  Should it?

child.EntityAspect.Delete();
EntityManager.RejectChanges();

Parent.children - does not contain child; however, the EntityManager does show the child with no changes AND its parent has been restored properly.

I'm unsure if this is proper behavior, but if it is, I'm not sure how to restore the child relationship.

Thanks for any help.



Edited by mikewishart - 02-Aug-2010 at 4:22pm
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 05-Aug-2010 at 4:50pm
Originally posted by mikewishart

In DevForce 6.0.4
Rejecting changes for the entire EntityManager does not seem to restore a parent's relationship to the deleted child.  Should it?

child.EntityAspect.Delete();
EntityManager.RejectChanges();

Parent.children - does not contain child; however, the EntityManager does show the child with no changes AND its parent has been restored properly.

I'm unsure if this is proper behavior, but if it is, I'm not sure how to restore the child relationship.

Thanks for any help.


This looks like a bug - the parent's collection of children should again contain the deleted and restored child.  I've reproduced it in a test case and created a Defect Report in our issue system.

I don't know of a good work-around, but I'll ask around for ideas.

Of course, if you know that a given entity belongs in a parent's collection of children of that type, you can explicitly add it to that collection.
Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 05-Aug-2010 at 5:07pm
Thanks Greg,  you've been a big help.

Mike
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 06-Aug-2010 at 7:42am
You're most welcome, Mike. Your very clear and nicely isolated reports are really a tremendous help to us in isolating and correcting problems in DevForce. We appreciate your patience!
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 10-Aug-2010 at 1:39pm
Originally posted by mikewishart

In DevForce 6.0.4
Rejecting changes for the entire EntityManager does not seem to restore a parent's relationship to the deleted child.  Should it?

child.EntityAspect.Delete();
EntityManager.RejectChanges();

Parent.children - does not contain child; however, the EntityManager does show the child with no changes AND its parent has been restored properly.

I'm unsure if this is proper behavior, but if it is, I'm not sure how to restore the child relationship.

Thanks for any help.


This bug has been fixed. Fix will be in the next release.
Back to Top
rhaney View Drop Down
Newbie
Newbie


Joined: 06-Jul-2010
Location: Orange, CA
Posts: 12
Post Options Post Options   Quote rhaney Quote  Post ReplyReply Direct Link To This Post Posted: 10-Aug-2010 at 5:07pm
Greg,
 
Can you also test one more thing?  I am unable to revert changes to a complex type.
 
In my model:
 
Name is a complex type having three string properties, First, Last, Middle.
Person has a complex property of type Name.
 
If I materialize a person, change the last name, and call revert changes, it doesn't revert the name.
 
Thanks!
Back to Top
rhaney View Drop Down
Newbie
Newbie


Joined: 06-Jul-2010
Location: Orange, CA
Posts: 12
Post Options Post Options   Quote rhaney Quote  Post ReplyReply Direct Link To This Post Posted: 10-Aug-2010 at 5:08pm
FYI, I call revert changes on the instance of Person.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down