• 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
Re: SharedEditingContext Write Locks?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SharedEditingContext Write Locks?


  • Subject: Re: SharedEditingContext Write Locks?
  • From: Lachlan Deck <email@hidden>
  • Date: Tue, 15 Nov 2005 12:45:20 +1100

Hi there,

On 15/11/2005, at 7:55 AM, Fabian Peters wrote:

as David said, EOSEC requires special care. OTTOMH I'd say the problem is caused by your use of "objectsWithQualifierFormat".

Agreed. From the EOSharedEditingContext docs:
"Objects can be fetched into a shared context using objectsWithFetchSpecification and bindObjectsWithFetchSpecification."


Doesn't look like you're following that scheme.

So...

Am 14.11.2005 um 21:06 schrieb Dov Rosenberg:
public static EOEditingContext actionEditingContext() {
	EOEditingContext ec = new EOEditingContext();
	ec.setSharedEditingContext(null);
	return ec;
}

Here's what I've got...

public class Application extends WOApplication {
<...>
/** @TypeInfo EOEnterpriseObject */
public NSArray refetchSharedRecordsForNamedEntity( String entityName ) {
EOFetchSpecification fetchSpec;

try {
//
// Use Custom FetchSpec if exists:
// public static EntityName.FetchSpecification()
//
Class entityClass;
Method fetchSpecMethod;

entityClass = classForEntityName( entityName );
fetchSpecMethod = entityClass.getMethod( "FetchSpecification", null );
fetchSpec = ( EOFetchSpecification )fetchSpecMethod.invoke ( entityClass, null );
} catch ( Exception e ) {
fetchSpec = new EOFetchSpecification( entityName, null, null );
}
return refetchSharedRecordsWithFetchSpecification( fetchSpec );
}


/** @TypeInfo EOEnterpriseObject */
public NSArray refetchSharedRecordsWithFetchSpecification ( EOFetchSpecification fetchSpec ) {
NSArray records;


try {
records = _sharedEditingContext.objectsWithFetchSpecification ( fetchSpec, _sharedEditingContext );
} catch ( RuntimeException rte ) {
System.err.println( "Refetch error for entity: " + entityName );
rte.printStackTrace( new PrintStream( new FileOutputStream ( FileDescriptor.err ) ) );
records = NSArray.EmptyArray;
}
return records;
}

/** @TypeInfo EOEnterpriseObject */
public NSArray sharedRecordsForNamedEntity( String entityName ) {
return ( NSArray )_sharedEditingContext.objectsByEntityName ().valueForKey( entityName );
}
}


You could try something like...

public UserInformation extends EOGenericRecord {
<...>
public static EOFetchSpecification FetchSpecification(Site site, String login) {
NSMutableArray qualifierArgs;
EOQualifier qualifier;


qualifierArgs = new NSArray(new Object[] { "login", login, "ownderSite", site });
qualifier = EOQualifier.qualifierWithQualifierFormat("%@ = %@ AND % @ = %@", args);

return new EOFetchSpecification("UserInformation", qualifier, null);
}
}


And perhaps change the offending code to look like:

public static NSArray userWithIDInSite(EOEditingContext ec, Site site, String login)
throws CVDatabaseException
{
NSArray userList = null;
NSMutableArray args = new NSMutableArray();
	Application app = ( Application )Application.application();

	args.addObject( login );
	args.addObject( site );

userList = app.refetchSharedRecordsWithFetchSpecification ( UserInformation.FetchSpecification( site, login ) );
if ( !ec.equals( app.sharedEditingContext() ) {
return EOUtilities.localInstancesOfObjects( ec, userList );
}
return userList;
}


This code is called using the shared editingcontext returned from

EOSharedEditingContext.defaultSharedEditingContext();

It can now be called using any ec... see how that goes.

Let us know how it turns out.

with regards,
--

Lachlan Deck


_______________________________________________ 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: SharedEditingContext Write Locks?
      • From: Dov Rosenberg <email@hidden>
References: 
 >SharedEditingContext Write Locks? (From: Dov Rosenberg <email@hidden>)
 >Re: SharedEditingContext Write Locks? (From: Fabian Peters <email@hidden>)

  • Prev by Date: Re: WOSwitchComponent?
  • Next by Date: Re: New WebObjects Builder User Guide
  • Previous by thread: Re: SharedEditingContext Write Locks?
  • Next by thread: Re: SharedEditingContext Write Locks?
  • Index(es):
    • Date
    • Thread