Re: EOSharedEditingContext
Re: EOSharedEditingContext
- Subject: Re: EOSharedEditingContext
- From: Chuck Hill <email@hidden>
- Date: Thu, 20 Dec 2007 21:45:36 -0800
There is no reason / value / use in (mis)using the shared editing
context like this. Use a regular editing context. Think of
EOSharedEditingContext as EOReadMostlyObjectStore and you will be a
lot better off.
Chuck
On Dec 20, 2007, at 9:34 PM, Jonathan Miller wrote:
Along those lines,
if EOUtilities static methods are not thread safe, how do you use a
shared editing context to make raw SQL calls?
e.g. how do I transform the following to a thread safe operation?
String sql = "SELECT MIN(NEWS_DATE) AS START_DATE FROM NEWS;";
NSArray<NSMutableDictionary<String, Object>> data =
EOUtilities.rawRowsForSQL
(EOSharedEditingContext.defaultSharedEditingContext(),
"ParadiseDB", sql, null);
Best,
Jon
Begin forwarded message:
From: Jonathan Miller <email@hidden>
Date: December 20, 2007 6:53:36 PM HST
To: email@hidden
Subject: re: EOSharedEditingContext
Hi Art,
I've received that advice before, but I've also watched a screen
cast from one of the WWDC events and the apple engineer strongly
recommends using the shared editing context. If I remember
correctly, the engineer stated that iTunes heavily utilizes the
shared editing context.
However, I'll go with your suggestion and stop using the static
eoutilities methods in place of the thread safe API.
Any comments?
Jon
How do I do the following without getting the pesky warning from
Eclipse about unchecked type conversion?
NSArray<NewsKeywords> newsKeywords =
EOUtilities
.objectsForEntityNamed
(EOSharedEditingContext.defaultSharedEditingContext(),
"NewsKeywords");
I wouldn't do the above in the first place. Just because an
EOSharedEditingContext extends EOEditingContext doesn't mean that it
IS an EOEditingContext. It's actually quite different and can be the
cause of considerable grief when not handled correctly (deadlocks and
other nasty behaviors). It's probably best to fetch shared objects
only early in an app's life (e.g., in the Application constructor) or
to mark objects as shared in one's eomodel which will cause them all
to be fetched when the first shared object is fetched.
NewsKeywords should be fetched into an EOSharedEditingContext using
its thread-safe API, objectsWithFetchSpecification() or
bindObjectsWithFetchSpecification(), and these fetched objects
accessed only using the thread-safe API, objectsByEntityName() or
objectsByEntityNameAndFetchSpecificationName(). You may be able to
avoid the unchecked type conversion warnings by doing so as well.
Aloha,
Art
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden