Questions Tagged With additional-propertyhttps://answers.axonivy.com/tags/additional-property/?type=rssquestions tagged <span class="tag">additional-property</span>enTue, 06 Jun 2017 06:25:16 -0400TaskQuery with additional propertyhttps://answers.axonivy.com/questions/2672/taskquery-with-additional-property<p>Hi everyone,</p> <p>I have the issue related to additional property in TaskQuery: Task A doesn't have any additional property and Task B has the "DISPLAY" additional property.</p> <pre><code>TaskQuery stateQuery = TaskQuery.create().where().state().isEqual(TaskState.SUSPENDED).or().state().isEqual(TaskState.RESUMED).or().state().isEqual(TaskState.PARKED); TaskQuery additionalPropertyQuery = TaskQuery.create().where().additionalProperty("HIDE").isNull(); TaskQuery query = TaskQuery.create().where().and(stateQuery).and(additionalPropertyQuery); </code></pre> <p>==&gt; The result of this query is only Task A. I expect that the result is A and B.</p> <p>Do you have any suggestions?</p>dolongTue, 06 Jun 2017 06:25:16 -0400https://answers.axonivy.com/questions/2672/taskquery-with-additional-propertyadditional-propertyivytask-queryWhy does Axon.ivy persist an ICase when `setAdditionalProperty` is invoked even if there is no TaskSwitch element?https://answers.axonivy.com/questions/1755/why-does-axon-ivy-persist-an-icase-when-setadditionalproperty-is-invoked-even-if-there-is-no-taskswitch-element<p>There written in the <a href="http://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.concepts.html#ivy-wf-states">public document</a>:</p> <blockquote> <p>Normally, a case is started non persistent. This means it is stored in memory only. As soon as the process hits a task switch the case and its tasks will be made persistent by storing them to the system database.</p> </blockquote> <p>I just found out that you can make an ICase persisted without any TaskSwitch element in the process by setting an <code>additionalProperty</code>.</p> <p>As soon as the line of code is evaluated:</p> <pre><code>ivy.case.setAdditionalProperty("anything-will-do", "some-value"); </code></pre> <p>The <code>ICase</code> will be persisted <em>immediately</em>.</p> <p>Is this a non-public behaviour or a bug in the API?</p> <p>P.S: there is a demo project to demonstrate this behaviour at <a href="https://www.mediafire.com/?hxi3z0v27dhjxh4">https://www.mediafire.com/?hxi3z0v27dhjxh4</a></p>Genzer HawkerFri, 29 Apr 2016 05:40:29 -0400https://answers.axonivy.com/questions/1755/why-does-axon-ivy-persist-an-icase-when-setadditionalproperty-is-invoked-even-if-there-is-no-taskswitch-elementcaseadditional-propertypersistenceworkflow`TaskQuery.and(TaskQuery)` and `CaseQuery.and(CaseQuery)` doesn't work with `additionalProperty()`.https://answers.axonivy.com/questions/1337/taskquery-and-taskquery-and-casequery-and-casequery-doesn-t-work-with-additionalproperty<p>On our project, we extensively uses the API <code>TaskQuery</code> and <code>CaseQuery</code> in order to find <code>ITask</code> and <code>ICase</code> respectively. We also make use of the <code>additionalProperty</code> of both <code>ITask</code> and <code>ICase</code> in order to store custom fields.</p> <p>However, we later found out that the method <code>and(TaskQuery</code> and <code>or(TaskQuery)</code> doesn't work with the criteria <code>additionalProperty</code>.</p> <p>Consider the below snippet of code:</p> <pre><code>public List&lt;ITask&gt; 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"); } </code></pre> <p>Runing the code will result as an exception:</p> <pre><code>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] </code></pre> <p>While this works:</p> <pre><code>public List&lt;ITask&gt; findTask() { Ivy.wf().getTaskQueryExecutor() .getResults(TaskQuery.create().where() .state().isEqual(SUSPENDED) .and().additionalProperty("custom").isLike("customized_value"); } </code></pre> <p>Please note that only the criterion <code>additionalPropety()</code> has this problem, the other criteria don't.</p> <p>Digging a little deeper, I found that the queries produced are different:</p> <p>The former (the problematic one) produces:</p> <pre><code>SELECT * FROM IWA_Task WHERE (Column(IWA_TaskQuery.State) = 4 &amp;amp;&amp;amp; ((Column(AdditionalPropertyForTask.Name) = custom || Column(AdditionalPropertyForTask.Name) IS NULL) &amp;amp;&amp;amp; Column(AdditionalPropertyForTask.Value) LIKE customized_value)) </code></pre> <p>...whereas the latter produces (correctly):</p> <pre><code>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 &amp;&amp; (Column(AdditionalPropertyForTask.Name) = custom || Column(AdditionalPropertyForTask.Name) IS NULL) &amp;&amp; Column(AdditionalPropertyForTask.Value) LIKE customized_value) </code></pre> <p>This problem occurs both on <code>TaskQuery</code> and <code>CaseQuery</code> and on Axon.ivy 5.1.x (<code>additionalProperty()</code> has been introduced since 5.1.x).</p> <p>I think this is probrably a bug in Axon.ivy query API. While there is a work-around (don't use <code>and(TaskQuery</code> with <code>additionalProperty()</code>), I think it is not good to have inconsistency in the API. I hope this would be fixed soon.</p> <p>I have created a demo project which can reproduce the problem on Axon.ivy. Download it at <a href="https://app.box.com/s/9wxc8iqqrfmqotljiutqdwlvvoem55dh">box.net</a>.</p>Genzer HawkerWed, 27 May 2015 09:04:31 -0400https://answers.axonivy.com/questions/1337/taskquery-and-taskquery-and-casequery-and-casequery-doesn-t-work-with-additionalpropertyadditional-propertycase-querybugtask-query