Issue Details (XML | Word | Printable)

Key: WF-489
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Hani Suleiman
Reporter: Sébastien Launay
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OSWorkflow

Nested expression query fails with Oracle (ORA-00933: SQL command not properly ended)

Created: 06/Apr/09 03:27 AM   Updated: 11/Oct/09 07:56 AM
Return to search
Component/s: Persistence Layer
Affects Version/s: 2.8
Fix Version/s: None

File Attachments: 1. Text File osworkflow-head-oracle-query-ORA-00933-2009-04-06.patch (3 kB)

Environment: Oracle 10g


 Description  « Hide
When running AbstractFunctionalWorkflowTest test case using Oracle database, the following code :

// --------------------------- empty nested query : AND
// ---------------------------------
Expression queryLeft = new FieldExpression(FieldExpression.OWNER, FieldExpression.CURRENT_STEPS, FieldExpression.EQUALS, USER_TEST);
Expression queryRight = new FieldExpression(FieldExpression.STATUS, FieldExpression.CURRENT_STEPS, FieldExpression.EQUALS, "Finished");
query = new WorkflowExpressionQuery(new NestedExpression(new Expression[] {queryLeft, queryRight}, NestedExpression.AND));
workflows = workflow.query(query);

fails with the exception:
com.opensymphony.workflow.StoreException: SQL Exception in query: ORA-00933: SQL command not properly ended
at com.opensymphony.workflow.spi.jdbc.JDBCWorkflowStore.doExpressionQuery(JDBCWorkflowStore.java:1197)
at com.opensymphony.workflow.spi.jdbc.JDBCWorkflowStore.query(JDBCWorkflowStore.java:621)

the query used is:
SELECT DISTINCT (a1.ENTRY_ID) AS retrieved FROM OS_CURRENTSTEP AS a1 , OS_CURRENTSTEP AS a2
WHERE a1.ENTRY_ID = a1.ENTRY_ID AND a1.ENTRY_ID = a2.ENTRY_ID AND ( a1.OWNER = 'test' AND a2.STATUS = 'Finished' )

This is because AS token is not supported in table reference (FROM) by Oracle.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Sébastien Launay added a comment - 06/Apr/09 03:52 AM
A patch for fixing this issue by:
- removing AS token from the query (FROM table AS a1)

The previous code was already SQL standard but fails with Oracle RDBM.
The modified code works with Oracle, Postgres, MySQL and i think will continue to work with other RDBMs.

LeonWong added a comment - 30/Sep/09 06:18 AM
I have the same problem.
I wanna know how you can modify the code in the class file which is in the osworkflow2.8.0 jar file

Sébastien Launay added a comment - 30/Sep/09 08:00 AM
You need to retrieve the 2.8.0 sources, then apply the patch attached on this issue and build osworkflow.
Another solution is to duplicate or inherit JDBCWorkflowStore class into a new one, change the code affected in the patch and to use it as the configured workflow store.

LeonWong added a comment - 11/Oct/09 07:56 AM
thank you for your help.