yes, now it works !!

Thank you very much!

Amedeo

new code below


  public void setIsPrimoPiano(Boolean value) {
        if (value) {
                
//EOUtilities.rawRowsForSQL(new EOEditingContext(), "WebConfindustria", "UPDATE CFArticle SET isPrimoPiano='false';",null); //THIS IS MY OLD WORKAROUND
                        
EOEditingContext ec = ERXEC.newEditingContext(); // <--- Kieran Patch !
                ec.setSharedEditingContext(null);
NSArray<CFArticle> array = (NSArray<CFArticle>)EOUtilities.objectsMatchingKeyAndValue(ec, "CFArticle", "isPrimoPiano", true);
                if (array!=null) {
                        for (int i=0 ; i < array.count() ; i++) {
                                array.objectAtIndex(i).setIsPrimoPiano(false);
                        }
                }
                  ec.saveChanges();
          }
          super.setIsPrimoPiano(value);
  }




On 27/feb/09, at 23:05, Kieran Kelleher wrote:

hey, did you see my email?

Try using ERXEC.newEditingContext() instead of new EoEditingContext()....

Let us know if that fixes it.

Kieran

On Feb 27, 2009, at 3:48 PM, Amedeo Mantica wrote:

yes, i have a shared eo...

in my Application i have:

        public void fetchArticles() {
EOSharedEditingContext sharedContext = EOSharedEditingContext.defaultSharedEditingContext();
                EOFetchSpecification fetchSpec;
                fetchSpec = new EOFetchSpecification("CFArticle",null,null);
articlesArray = sharedContext.objectsWithFetchSpecification(fetchSpec);
        }

then I have put

EOEditingContext ec = new EOEditingContext();
ec.setSharedEditingContext(null);

in my method.


The goal is this...

CFArticle is an entity of articles, I fetch all articles at the application launch in the SharedEC, i do occasionally, or invoked by some action, updates to my fetch


the key primoPiano ( in english may be translated in highLight ) is a boolean value that I can set

Only ONE article can have primopiano=true

the primoPiano article is put in my website homepage


so the method setIsPrimoPiano in the CFArticle entity should check and reset eventually all primopiano flags to false and there is where i have the trouble.


just for see, the webste is: http://www.confindustria.chieti.it

Best Regards
Thank You
Amedeo


On 27/feb/09, at 19:22, Chuck Hill wrote:

Mike made me look at your code again. That is a terrible thing to do in a set method. I don't know what you are doing or the context you are doing it in, but this seems slightly less awful:

public void setIsPrimoPiano(Boolean value) {
        if (value) {
NSArray<CFArticle> array = (NSArray < CFArticle >)EOUtilities.objectsMatchingKeyAndValue(editingContext(), "CFArticle", "isPrimoPiano", true);
                 if (array!=null) {
                         for (int i=0 ; i < array.count() ; i++) {
                                 array.objectAtIndex(i).setIsPrimoPiano(false);
                         }
                 }
         }
         super.setIsPrimoPiano(value);
}

Note that if CFArticle _is_ in the shared editing context that you have a larger problem.


Chuck


On Feb 27, 2009, at 9:59 AM, Chuck Hill wrote:

It is almost certainly something that you did in your code. ERXGenericRecord$InverseRelationshipUpdater seems to be involved, so maybe ask about that on the Wonder list.

Chuck


On Feb 27, 2009, at 2:11 AM, Amedeo Mantica wrote:

any news?

Thanks
Amedeo


On 24/feb/09, at 18:40, Amedeo Mantica wrote:

but that code was working some day ago... is really strange

at the moment I have "solved" using raw sql

EOUtilities.rawRowsForSQL(new EOEditingContext(), "WebConfindustria", "UPDATE CFArticle SET isPrimoPiano='false';",null);

but this is not a solutions, is just a trick...

Amedeo

On 24/feb/09, at 18:25, Amedeo Mantica wrote:

absolutely not

Amedeo

On 24/feb/09, at 18:11, Chuck Hill wrote:

Have you overridden awakeFromFetch and not called super.awakeFromFetch?

Chuck


On Feb 24, 2009, at 8:22 AM, Amedeo Mantica wrote:

This is new to me....



public void setIsPrimoPiano(Boolean value) {
        if (value) {
                  EOEditingContext ec = new EOEditingContext();
ec.setSharedEditingContext(null); // I set null to shared EO because i fetch all in application LINE 42 ---> NSArray<CFArticle> array = (NSArray <CFArticle>)EOUtilities.objectsMatchingKeyAndValue(ec, "CFArticle", "isPrimoPiano", true);
                  if (array!=null) {
                          for (int i=0 ; i < array.count() ; i++) {
                                  array.objectAtIndex(i).setIsPrimoPiano(false);
                          }
                  }
                  ec.saveChanges();
          }
          super.setIsPrimoPiano(value);
}




Attempt to access an EO that has either not been inserted into any EOEditingContext or its EOEditingContext has already been disposed


com .webobjects .eocontrol.EOCustomObject.willRead(EOCustomObject.java:1158) com.webobjects.eocontrol._EOMutableKnownKeyDictionary $Initializer $ _GenericRecordBinding .valueInObject(_EOMutableKnownKeyDictionary.java:570) com.webobjects.eocontrol._EOMutableKnownKeyDictionary $Initializer $ _LazyGenericRecordBinding .valueInObject(_EOMutableKnownKeyDictionary.java:613) com .webobjects .eocontrol .EOCustomObject.storedValueForKey(EOCustomObject.java:1634) it.chieti.confindustria._CFArea.articles(_CFArea.java:103) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun .reflect .NativeMethodAccessorImpl .invoke(NativeMethodAccessorImpl.java:39) sun .reflect .DelegatingMethodAccessorImpl .invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) com.webobjects.foundation.NSKeyValueCoding$ValueAccessor $1.methodValue(NSKeyValueCoding.java:636) com.webobjects.foundation.NSKeyValueCoding $_MethodBinding.valueInObject(NSKeyValueCoding.java:1134) com .webobjects .eocontrol.EOCustomObject.valueForKey(EOCustomObject.java: 1498) er.extensions.eof.ERXGenericRecord $ InverseRelationshipUpdater .takeStoredValueForKey(ERXGenericRecord.java:1431) er .extensions .eof .ERXGenericRecord .takeStoredValueForKey(ERXGenericRecord.java:1217) com.webobjects.eocontrol.EOKeyValueCoding $ _StoredForwardingBinding .setValueInObject(EOKeyValueCoding.java:240) com .webobjects .eoaccess .EODatabaseContext .initializeObjectRowEntityEditingContext (EODatabaseContext.java:2246) com .webobjects .eoaccess .EODatabaseContext.initializeObject(EODatabaseContext.java: 3581) com .webobjects .eocontrol .EOObjectStoreCoordinator .initializeObject(EOObjectStoreCoordinator.java:597) com .webobjects .eocontrol .EOEditingContext.initializeObject(EOEditingContext.java: 3768) com.webobjects.eoaccess.EODatabaseChannel $ _EODatabaseChannelFetchResult .initializeObjects(EODatabaseChannel.java:496) com .webobjects .eoaccess .EODatabaseContext ._objectsWithFetchSpecificationEditingContext (EODatabaseContext.java:3090) com .webobjects .eoaccess .EODatabaseContext .objectsWithFetchSpecification(EODatabaseContext.java:3195) com .webobjects .eocontrol .EOObjectStoreCoordinator .objectsWithFetchSpecification(EOObjectStoreCoordinator.java: 488) com .webobjects .eocontrol .EOEditingContext .objectsWithFetchSpecification(EOEditingContext.java:4069) com .webobjects .eocontrol .EOEditingContext .objectsWithFetchSpecification(EOEditingContext.java:4444) com .webobjects .eoaccess.EOUtilities.objectsMatchingValues(EOUtilities.java: 216) com .webobjects .eoaccess .EOUtilities.objectsMatchingKeyAndValue(EOUtilities.java: 190) it .chieti .confindustria.CFArticle.setIsPrimoPiano(CFArticle.java:42)

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected] )
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net

This email sent to [email protected]

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects








_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Webobjects- [email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/amedeomailing%40insigno.it

This email sent to [email protected]


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/amedeomailing%40insigno.it

This email sent to [email protected]


--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects








_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%40mac.com

This email sent to [email protected]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to