Hi, I need some help please.
Fig 1 shows the code. Fig 2. shows the log output where I am getting a class cast exception in private eoaccess class. Now, if I take out the endEqualsNullQualifier element out of the construct and replace the endQualifiers in the total qualifier with just the endGreaterThanNowQualifier, I get no errors. .... any ideas what I am doing wrong here?
Fig 1 .... the code to construct the qualifier // Fetch past due, active ScheduledTasks.....
// Active tasks NSTimestamp now = new NSTimestamp();
// START DATE QUALIFIER // The start date must be less than now EOQualifier startLessThanNowQualifier = new EOKeyValueQualifier( "startDate", EOQualifier.QualifierOperatorLessThanOrEqualTo, now );
// END DATE QUALIFIER // The end date can be null meaning "no end date" EOQualifier endEqualsNullQualifier = new EOKeyValueQualifier( "endDate", EOQualifier.QualifierOperatorEqual, NSKeyValueCoding.NullValue );
// OR the end date can be not null and greater than now EOQualifier endGreaterThanNowQualifier = new EOKeyValueQualifier( "endDate", EOQualifier.QualifierOperatorGreaterThanOrEqualTo, now );
NSMutableArray endQualifiersArray = new NSMutableArray( endEqualsNullQualifier ); endQualifiersArray.addObject( endGreaterThanNowQualifier ); EOQualifier endQualifiers = new EOOrQualifier( endQualifiersArray );
// NEXT EVENT DUE QUALIFIER // The nextEvent Due must be less than now EOQualifier nextEventDueQualifier = new EOKeyValueQualifier( "nextEventDue", EOQualifier.QualifierOperatorLessThan, now );
// TOTAL FETCH QUALIFIER // Construct the final qualifier // ( endDate > now OR endDate is null ) AND (startDate < now ) AND ( nextEventDue < now ) NSMutableArray totalQualifiersArray = new NSMutableArray( startLessThanNowQualifier ); totalQualifiersArray.addObject( endQualifiersArray ); totalQualifiersArray.addObject( nextEventDueQualifier ); EOQualifier totalQualifier = new EOAndQualifier( totalQualifiersArray );
if ( log.isDebugEnabled() ) log.debug("totalQualifier = " + totalQualifier );
// Create a due date sort ordering so the tasks get executed in order // of oldest first EOSortOrdering sortOrdering = new EOSortOrdering( "nextEventDue", EOSortOrdering.CompareAscending );
EOFetchSpecification fs = new EOFetchSpecification( "CTScheduledTask", totalQualifier, new NSArray( sortOrdering ), false, false, null );
if ( log.isDebugEnabled() ) log.debug("Fetch Spec = " + fs );
NSArray dueTasks = ec.objectsWithFetchSpecification( fs );
Fig 2. The log output and error stack trace:
17018 DEBUG [Thread-1] (STEDispatcher, processScheduledTasks, 90) - totalQualifier = ((startDate <= (com.webobjects.foundation.NSTimestamp)'2006-04-11 16:36:06 Etc/GMT') and ((endDate = null), (endDate >= (com.webobjects.foundation.NSTimestamp)'2006-04-11 16:36:06 Etc/GMT')) and (nextEventDue < (com.webobjects.foundation.NSTimestamp)'2006-04-11 16:36:06 Etc/GMT'))
17020 DEBUG [Thread-1] (STEDispatcher, processScheduledTasks, 104) - Fetch Spec = <class com.webobjects.eocontrol.EOFetchSpecification(entityName=CTScheduledTask, qualifier=((startDate <= (com.webobjects.foundation.NSTimestamp)'2006-04-11 16:36:06 Etc/GMT') and ((endDate = null), (endDate >= (com.webobjects.foundation.NSTimestamp)'2006-04-11 16:36:06 Etc/GMT')) and (nextEventDue < (com.webobjects.foundation.NSTimestamp)'2006-04-11 16:36:06 Etc/GMT')), isDeep=false, usesDistinct=false, sortOrdering=(<class com.webobjects.eocontrol.EOSortOrdering(nextEventDue compareAscending)>), hints=null, _prefetchingRelationshipKeyPaths = null)>
17328 ERROR [Thread-1] (STEDispatcher, processScheduledTasks, 152) - Exception while processing scheduled tasks
java.lang.ClassCastException at com.webobjects.eoaccess.EOQualifierSQLGeneration$_AndQualifierSupport.schemaBasedQualifierWithRootEntity(EOQualifierSQLGeneration.java:501) at com.webobjects.eoaccess.EOQualifierSQLGeneration$Support._schemaBasedQualifierWithRootEntity(EOQualifierSQLGeneration.java:165) at com.webobjects.eoaccess.EODatabaseChannel.selectObjectsWithFetchSpecification(EODatabaseChannel.java:209) at com.webobjects.eoaccess.EODatabaseContext._objectsWithFetchSpecificationEditingContext(EODatabaseContext.java:3205) at com.webobjects.eoaccess.EODatabaseContext.objectsWithFetchSpecification(EODatabaseContext.java:3346) at com.webobjects.eocontrol.EOObjectStoreCoordinator.objectsWithFetchSpecification(EOObjectStoreCoordinator.java:539) at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4114) at er.extensions.ERXEC.objectsWithFetchSpecification(ERXEC.java:557) at com.webobjects.eocontrol.EOEditingContext.objectsWithFetchSpecification(EOEditingContext.java:4500) at STEDispatcher.processScheduledTasks(STEDispatcher.java:106) at STEDispatchTimerTask.run(STEDispatchTimerTask.java:23) at java.util.TimerThread.mainLoop(Timer.java:432) at java.util.TimerThread.run(Timer.java:382)
|