Re: [Modeling-users] dirty deeds done dirt cheap
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2004-03-25 00:02:47
|
Marcos Dione <md...@vi...> wrote: >=20 > On Wed, Mar 24, 2004 at 05:19:41PM -0300, Marcos Dione wrote: > > flipping the docs I see that EditingContext is capable of tell > > wether it's dirty or not. but I think it would be better if I could ask > > the Entity if it's dirty or not; and, being dirty, ask it to ignore any > > changes not saved (which I think will resort to reload from the db)...= =20 >=20 > I note two things: first, asking an Entity if it's dirty or not is > impossible w/o an EC, so is unreasonable to ask for it. Absolutely, the standard way is to ask the ec for that --even if some of the CustomObject's methods can be relative to the editingContext(), such as globalID(). > second, the > answer seems to be to use nested EC's, but if I do it that way, for > reseting I would need to discard the dirty EC, take a new one and > repopulate it with the original values (most probably this two EC's will > be child of one master EC at different times). >=20 > what's not clear for me is how to repopulate the second EC. Repopulating the EC simply consists in fetching the objects, or asking for a particular object given its globalID (ec.faultForGlobalID()), etc. Now you may need a simpler way of doing this, esp. if you're dealing with one object or a few: the nested ECs are very handy when the modifications of the graph of objects can be very intensive and you do not want to track which changes occured. But if you know exactly which object(s) is/are impacted (which is probably the case in any simple form), you may just ask for forgetting about the changes --what you were asking for in your 1st post. I've just submitted patch #922822 with an up-to-date version of one I posted a year ago (almost: 26 Mar 2003 :/ ) https://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D922822&group_= id=3D58935&atid=3D489337 The comments there contain references of the messages talking about this feature. It also contains a test case for that. The idea is that you simply call ec.refaultObject(obj), and the object is reverted back to a fault, ready to be retrieved from the database next time one of its properties' value is needed. It's not been extensively tested, and should be used w/ care for the moment being; see comments for patch #922822. As noted there, it's been asked regularly, but even then I've never heard that it has been really tested. Handle w/ care ;) but hopefully it will be of some help, and maybe we could finally make it and finally integrate this into the main trunk some day. So I'll be happy to hear from you if you find some time to experiment! -- S=E9bastien. |