Le 12 mai 2011 à 19:33, Fred Wells a écrit :
Almost but the SQL that get generated isn't
right, any one know a way around this error?
EvaluateExpression failed: <com.webobjects.jdbcadaptor.MicrosoftPlugIn$MicrosoftExpression:
"SELECT DISTINCT t0.actualEndDate, t0.actualStartDate, t0.approvalOutput,
t0.childNbr, t0.description, t0.duration, t0.duration_days, t0.duration_hours,
t0.endDate, t0.fkParentTaskId, t0.fk_approval_user_id, t0.fk_jobTemplate_id,
t0.fk_job_id, t0.fk_phase_id, t0.fk_status_id, t0.fk_taskType_id, t0.fk_workgroup_id,
t0.idForTemplate, t0.isActive, t0.name, t0.overdueNotified, t0.pkid, t0.startDate,
t0.threshold, t0.thresholdNotified, t0.threshold_days, t0.threshold_hours,
t0.xCoordinate, t0.yCoordinate FROM Task t0 WHERE (not ( EXISTS ( SELECT
t1.pkid FROM Task t1, UserTask T1 WHERE T1.taskPkid is not NULL AND t1.pkid
= T1.taskPkid AND t1.pkid = t0.pkid ) ) AND t0.fk_jobTemplate_id is NULL
AND t0.isActive = ? AND t0.fk_workgroup_id = ? AND (t0.fk_status_id = ?
OR t0.fk_status_id = ? OR t0.fk_status_id = ?))" withBindings: 1:"Y"(isActive),
2:4(fk_workgroup_id), 3:4(fk_status_id), 4:5(fk_status_id), 5:2(fk_status_id)>:
Next exception:SQL State:S1000 -- error code: 1011 -- msg: The correlation
name 'T1' is specified multiple times in a FROM clause
Here's my list of qualifiers:
EOQualifier qA = ERXQ.or(ERXQ.equals("status",Status.startedStatus(editingContext())),ERXQ.equals("status",Status.lateStatus(editingContext())),ERXQ.equals("status",Status.thresholdStatus(editingContext())));
EOQualifier qB = ERXQ.equals("workgroup",
user.workgroup());
EOQualifier qC = ERXQ.equals("isActive",
strY);
EOQualifier qD = ERXQ.isNull("jobTemplate");
EOQualifier qE = ERXQ.not(new ERXExistsQualifier(ERXQ.isNotNull("userTasks.taskPkid"),
"pkid"));
Hmm I guess you have Task ->> UserTask ... try something like that instead :
EOQualifier qE = new ERXExistsQualifier(ERXQ.isNotNull(UserTask.ID_KEY), "userTasks");
This qualifier should fetch all Tasks having some userTasks...the first argument in ERXExistsQualifier should be optional in this case, but it doesn't allow a null qualifier...
You should test this first, then try it with your rather big qualifier. This single qualifier in a fspec "should" generate this SQL :
SELECT ... FROM TASK t0 WHERE EXISTS (SELECT t1.ID FROM USER_TASK t1 WHERE t1.ID is not NULL AND t1.ID_TASK = t0.ID)
However, I've done a quick test and it generates wrong SQL, something like :
SELECT ... FROM TASK t0 WHERE EXISTS (SELECT t1.ID FROM USER_TASK t1 WHERE t1.ID is not NULL AND t1.ID = t0.ID)
So, either i'm doing it wrong or there's a small bug in this qualifier (generates primary key column instead of foreign key), i've corrected it in my workspace.
But i'm curious to hear from the others, is there someone else using this qualifier successfully ?