Re: issue with a nested editing context [long]
Re: issue with a nested editing context [long]
- Subject: Re: issue with a nested editing context [long]
- From: Chuck Hill <email@hidden>
- Date: Thu, 3 Jun 2004 11:56:57 -0700
On Jun 3, 2004, at 11:29 AM, Marius Strumyla wrote:
The problem you are seeing stems from the fact that 2 copies of your
EO
exist:
one in each editing context.
Exactly. I didn't find a way to propagate a regular (as opposed to db)
attribute changes between nested and parent ECs.
Save the nested EC. This updates only the parent, not the DB. Saving
the parent after this propogates the changes to the DB and other
editing contexts.
Chuck
So I went the easy way and switched the default value of
mRequiredProperties. It is
empty by default.
Now default editing context sees an empty mRequiredProperties. Nested
editing context sees
properties which need to be validated. I can now define at runtime
which
properties I want
to validate.
thanks for your suggestions
--
marius
-----Original Message-----
From: email@hidden [mailto:email@hidden]
Sent: Friday, May 07, 2004 3:15 AM
To: email@hidden; email@hidden
Subject: RE: issue with a nested editing context [long]
Hi!
The problem you are seeing stems from the fact that 2 copies of your EO
exist: one in each editing context.
On a side note: the implementation using a vector is not the most
appropriate. A NSSet or HashSet would be faster to lookup things.
If you always want to have your validation exceptions to be common
among all
nested EC, I would suggest moving the representation of your set of
properties to validate to a common location.
You could either move things up to the EO in the root EC or to a hash
table
in your root EC. In your root EC you might want to have a WeakHashMap
indexed by EOGlobalID. At validation time, an EO would first lookup
the root
EC (the one where the parent is not an EOEditingContext, or the first
to
have the map of keys to validate) and then grab the HashSet of keys to
validate from a WeakHashMap referenced by that EC.
Pierre
-----Original Message-----
From: email@hidden
[mailto:email@hidden]On Behalf Of Marius
Strumyla
Sent: Friday, May 07, 2004 12:35 AM
To: WOdev List
Subject: issue with a nested editing context [long]
Hello everybody,
I have a nested editing context.
EOEditingContext ctx = new
EOEditingContext(session().defaultEditingContext());
I fetch some EO objects through it. My EOs have a couple of attributes
-
property1 and property2. Both attributes have validate methods in my
EO:
public String validateProperty1(String new) { ... }
public String validateProperty2(String new) { ... }
Sometimes I need to validate the properties sometimes I don't. So in EO
contructor I create a vector which properties to validate. In validate
methods, I just check whether the vector contains the property:
public String validateProperty1(String new) {
// If vector doesn't contain the property, don't validate it.
if (!mRequiredProperties.contains("property1")) return new;
// else validate the property
...
}
If I decide I don't want to validate the EO. I clear the property
vector:
public void dontValidate() {
mRequiredProperties = new Vector();
}
=== So here goes my scenario: ===
1. I fetch the eo object through the nested ec
2. I change the object's properties
3. I decide not validate them, clear the mRequiredProperties vector
4. I save the EO
ctx.saveChanges();
session().defaultEditingContext().saveChanges();
=== Here's the problem: ===
I call saveChanges() twice. So validateProperty1 is called twice.
First time
it is called from ctx.saveChanges() stack. Second time it called from
session().defaultEditingContext().saveChanges() stack.
When it's called the second time, validateProperty1 sees the original
mRequiredProperties. That means that it is not empty and tries to
validate
the property1.
So how do I propagate mRequiredProperties's change from a child ec to
the
default ec?
Any help is much appreciated
--
marius
The information transmitted in this E-mail is intended only for the
person
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of,
or
taking of any action in reliance upon, this information by persons
other
than the intended recipient is prohibited. If you received this in
error,
please contact the sender and delete the material from any computer.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
The information transmitted in this E-mail is intended only for the
person
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of,
or
taking of any action in reliance upon, this information by persons
other
than the intended recipient is prohibited. If you received this in
error,
please contact the sender and delete the material from any computer.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.