On our project, we extensively uses the API TaskQuery and CaseQuery in order to find ITask and ICase respectively. We also make use of the additionalProperty of both ITask and ICase in order to store custom fields.

However, we later found out that the method and(TaskQuery and or(TaskQuery) doesn't work with the criteria additionalProperty.

Consider the below snippet of code:

public List<ITask> findTask() {
    Ivy.wf().getTaskQueryExecutor()
            .getResults(TaskQuery.create().where()
                    .state().isEqual(SUSPENDED)
                    .and(hasCustomField()));
}

private static TaskQuery hasCustomField() {
    return TaskQuery.create().where().additionalProperty("custom").isLike("customized_value");
}

Runing the code will result as an exception:

java.sql.SQLException: Column not found: ADDITIONALPROPERTYFORTASK.NAME in statement [SELECT IWA_TASKQUERY.TASKID ....... FROM IWA_TaskQuery WHERE (IWA_TASKQUERY.APPLICATIONID = ? AND (IWA_TASKQUERY."STATE" = ? AND ((ADDITIONALPROPERTYFORTASK.NAME = ? OR ADDITIONALPROPERTYFORTASK.NAME IS NULL) AND ADDITIONALPROPERTYFORTASK."VALUE" LIKE ?))) ORDER BY IWA_TASKQUERY.TASKID ASC]

While this works:

public List<ITask> findTask() {
    Ivy.wf().getTaskQueryExecutor()
            .getResults(TaskQuery.create().where()
                    .state().isEqual(SUSPENDED)
                    .and().additionalProperty("custom").isLike("customized_value");
}

Please note that only the criterion additionalPropety() has this problem, the other criteria don't.

Digging a little deeper, I found that the queries produced are different:

The former (the problematic one) produces:

SELECT * FROM IWA_Task WHERE
 (Column(IWA_TaskQuery.State) = 4 &amp;&amp;
 ((Column(AdditionalPropertyForTask.Name) = custom || Column(AdditionalPropertyForTask.Name) IS NULL)
    &amp;&amp; Column(AdditionalPropertyForTask.Value) LIKE customized_value))

...whereas the latter produces (correctly):

SELECT *  FROM IWA_Task 
LEFT JOIN IWA_TaskAdditionalProperty ON Column(IWA_TaskQuery.TaskId) = Column(IWA_TaskAdditionalProperty.TaskId)
LEFT JOIN IWA_AdditionalProperty ON Column(IWA_TaskAdditionalProperty.AdditionalPropertyId) = Column(IWA_AdditionalProperty.AdditionalPropertyId)
WHERE (Column(IWA_TaskQuery.State) = 4 && (Column(AdditionalPropertyForTask.Name) = custom || Column(AdditionalPropertyForTask.Name) IS NULL) && Column(AdditionalPropertyForTask.Value) LIKE customized_value)

This problem occurs both on TaskQuery and CaseQuery and on Axon.ivy 5.1.x (additionalProperty() has been introduced since 5.1.x).

I think this is probrably a bug in Axon.ivy query API. While there is a work-around (don't use and(TaskQuery with additionalProperty()), I think it is not good to have inconsistency in the API. I hope this would be fixed soon.

I have created a demo project which can reproduce the problem on Axon.ivy. Download it at box.net.

asked 27.05.2015 at 09:04

Genzer%20Hawker's gravatar image

Genzer Hawker
(suspended)
accept rate: 66%

edited 02.09.2015 at 15:42

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958


Thanks for reporting and the created demo project.

I have just analysed and fixed the API for Axon.ivy 5.1. The next Hotfix is 5.1.6 and will be available on our download page till the end of next week.

Fore more info or notifications see Issue

#25579: additionalProperty() does not work with TasQuery or CaseQuery when using .or(..), .and(..) or .not(..)
link

answered 01.07.2015 at 16:09

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦
(suspended)
accept rate: 75%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×10
×3
×3
×2

Asked: 27.05.2015 at 09:04

Seen: 4,372 times

Last updated: 02.09.2015 at 15:42