• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Stale data in EC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Stale data in EC


  • Subject: Stale data in EC
  • From: Eric Stewart <email@hidden>
  • Date: Fri, 2 Dec 2005 11:26:44 -0500

Hello everyone,

I'm having a problem where it appears I'm getting stale data from the
editing context.

I have a direct action that is inserting keywords into a database
table. The word itself (called "descriptor") is unique because I don't
want the same keyword in the system twice.

When a direct action request comes in for information about that
keyword, I check to see if that keyword is already in the system. If
not I add it.

Here is the code I use to check for that keyword.

/**
	 * Determines whether a new keyword with the given descriptor is
present in the system.
	 */
	public static boolean isPresentByDescriptor(EOEditingContext ec,
String descriptor) {
		NSDictionary args = new NSDictionary(descriptor, "descriptor");
		EOQualifier qual = EOQualifier.qualifierToMatchAllValues(args);
		EOFetchSpecification fs = new EOFetchSpecification("NewKeyword", qual, null);

		// Make sure we fetch fresh data
		fs.setRefreshesRefetchedObjects(true);

		// Find the keyword matching value
		NSArray keywords = ec.objectsWithFetchSpecification(fs);
		if (keywords.count() == 0) {
			// No match found
			return false;
		} else if (keywords.count() > 1) {
			// More than one match found
			if (NSLog.debugLoggingAllowedForLevel(NSLog.DebugLevelCritical)) {
				NSLog.debug.appendln("Duplicate new keyword found matching: " + descriptor);
			}
			return true;
		} else {
			// Match found return the keyword
			return true;
		}
	}

What is happening is I'm getting a lot of exceptions complaining that
a keyword being added to the system is not unique, hence I can only
guess that data from the EC is stale and is not reflecting newly
inserted keywords.

This direct action is running on an application that has around 20
instances running. So some how one of the other instances is inserting
a new keyword and the other instances continue to report it as not
being there.

Should I be using EditingContext.refaultAllObjects() or will this not
solve my problem. What I don't want to happen is for this to severely
degrade the performance of the application. I think I remember
EditingContext.invalidateAllObjects() causing a pretty poor
performance on high load applications, which this is. Is there some
other way to check whether the keyword is in the system or not before
it's added without incurring such a severe penalty?

Is there anyway to refault JUST the data in a certain table or of a
certain type of EO and not all the data in an EditingContext.

- Eric
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Stale data in EC
      • From: Chuck Hill <email@hidden>
  • Prev by Date: Re: Where to set display group bindings i java-file
  • Next by Date: Re: Where to set display group bindings i java-file
  • Previous by thread: Re: many-to-many relationship
  • Next by thread: Re: Stale data in EC
  • Index(es):
    • Date
    • Thread