Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SharedEditingContext Write Locks?



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: http://lists.apple.com/mailman/options/webobjects-dev/email@hidden

This email sent to email@hidden
References: 
 >SharedEditingContext Write Locks? (From: Dov Rosenberg <email@hidden>)
 >Re: SharedEditingContext Write Locks? (From: Fabian Peters <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.