Re: Trying to clear a dead-lock of some type
Re: Trying to clear a dead-lock of some type
- Subject: Re: Trying to clear a dead-lock of some type
- From: WebObjects <email@hidden>
- Date: Thu, 19 May 2005 18:24:43 -0700
Many thanks!
setRefreshesRefetchedObjects <--- this is a new one on me
After reading about this I realized there is yet another jillion things I'm
shy of knowing about.
Thank you all,
-Bill
on 5/19/05 13:49, Chuck Hill at email@hidden wrote:
> In addition to all the other good advice...
>
> public void SearchForSixAMTasks() {
>
> TimeZone tz = TimeZone.getTimeZone("Etc/GMT");
> NSTimestamp SixAM = new NSTimestamp(1899, 12, 30, 14, 2, 0, tz);
> NSMutableArray args = new NSMutableArray();
> args.addObject(SixAM);
> args.addObject("0");
> EOQualifier qualifier =
> EOQualifier.qualifierWithQualifierFormat("starttime = %@ AND
> taskcompletedindicator = %@", args);
> EOFetchSpecification spec = new EOFetchSpecification("Tbltasks",
> qualifier, null);
> spec.setRefreshesRefetchedObjects(true); // Use fresh data
>
> EOEditingContext ec = new EOEditingContext();
> ec.lock();
>
> try {
> NSArray array = ec.objectsWithFetchSpecification(spec);
> NSMutableArray foundTasks = new NSMutableArray(array);
>
> Enumeration e = foundTasks.objectEnumerator();
> while(e.hasMoreElements()) {
> Tbltasks currentTask = (Tbltasks)e.nextElement();
> // TaskReview is a process, not an EO - right?
> TaskReview review = new TaskReview();
> System.out.println(currentTask.taskcomment() + " -
> before
> change.");
>
> review.GetRepsData(currentTask); //data is
> read,modified,etc. in this method
>
> System.out.println(currentTask.taskcompletedindicator());
> System.out.println(currentTask.alarmindicator());
> }
>
> ec.saveChanges();
> } catch (Exception e) {
> // - Definite potential for locking issues with TPE, but
> only when intentionally trying to break it
> System.out.println("RepeatingTask: exception in
> SearchForSixAMTasks()");
> }
> finally {
> ec.unlock();
> ec.dispose();
> }
> }
>
> On May 19, 2005, at 12:22 PM, WebObjects wrote:
>
>> The following function works consistently, unless there is some
>> contention
>> (I'm sharing a datasource with other applications). There is the
>> expected
>> issue of saving to a locked row - but even if I trap the exception,
>> then
>> repeat this function some time later (after I'm certain the other apps
>> are
>> not locking the same rows) I still get the same contention.
>>
>> First, do you see anything in this method that is out of place or
>> sequence?
>> (it occurs in a TimerTask within Application) I'm not 100% certain
>> that my
>> ec.refreshAllObjects is place in the proper place.
>>
>> Advice is greatly appreciated!
>>
>> -Bill
>>
>>
>> public void SearchForSixAMTasks() {
>>
>> try{
>>
>> TimeZone tz = TimeZone.getTimeZone("Etc/GMT");
>> NSTimestamp SixAM = new NSTimestamp(1899, 12, 30, 14, 2, 0,
>> tz);
>> NSMutableArray args = new NSMutableArray();
>> args.addObject(SixAM);
>> args.addObject("0");
>> EOQualifier qualifier =
>> EOQualifier.qualifierWithQualifierFormat("starttime = %@ AND
>> taskcompletedindicator = %@", args);
>>
>>
>> EOFetchSpecification spec = new
>> EOFetchSpecification("Tbltasks",
>> qualifier, null);
>>
>>
>> EOEditingContext ec = new EOEditingContext();
>> ec.refreshAllObjects();
>>
>> //lock EC
>> ec.lock();
>>
>> //Fetch
>> NSArray array = ec.objectsWithFetchSpecification(spec);
>> NSMutableArray foundTasks = new NSMutableArray(array);
>>
>>
>> Enumeration e = foundTasks.objectEnumerator();
>>
>> while(e.hasMoreElements()) {
>>
>> Tbltasks currentTask = (Tbltasks)e.nextElement();
>> TaskReview review = new TaskReview();
>>
>> System.out.println(currentTask.taskcomment() + " -
>> before
>> change.");
>>
>> review.GetRepsData(currentTask); //data is
>> read,modified,etc. in this method
>>
>>
>> System.out.println(currentTask.taskcompletedindicator());
>>
>> System.out.println(currentTask.alarmindicator());
>>
>> }
>>
>> ec.saveChanges();
>>
>> //-- unlock EC
>> ec.unlock();
>> ec.refreshAllObjects();
>>
>>
>> } catch (Exception e) {
>>
>> // - Definite potential for locking issues with
>> TPE, but
>> only when intentionally trying to break it
>> System.out.println("RepeatingTask: exception in
>> SearchForSixAMTasks()");
>>
>> }
>>
>> }
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> village.net
>>
>> This email sent to email@hidden
>>
_______________________________________________
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