Uploaded image for project: 'Red Hat Process Automation Manager'
  1. Red Hat Process Automation Manager
  2. RHPAM-3968

Computed Order by CREATEDON is not working for normal queries

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not a Bug
    • Icon: Major Major
    • None
    • 7.11.1.GA
    • jBPM Core
    • None
      • Red Hat Process Automation Manager (RHPAM) 7.11.1
      • PostgreSQL 10.18 
    • False
    • False
    • 2022 Week 14-16 (from Apr 4)

      Customer noticed that if they use "order-by-clause":"CREATEDON desc" in their custom queries, the order is not correct. When they use "order-by-clause":"createdon desc" the order is correct.
       
      I could see the same behaviour in my environment. Also, this seems to be the problem in the latest version of RHPAM. It worked fine in previous versions. The database is Postgres.
       
      For instance, the result of the following custom query:
       
      {
        "query-name" : "jbpmHumanTasksPO",
        "query-source" : "${org.kie.server.persistence.ds}",
        "query-expression" : "select t.id as TASKID, t.name as NAME,  t.FORMNAME AS FORMNAME, t.description as DESCRIPTION, t.subject as SUBJECT, t.actualowner_id as actualowner, po.entity_id as POTOWNER, p.processinstancedescription as PROCESSINSTANCEDESCRIPTION, t.CREATEDON as CREATEDON, t.CREATEDBY_ID as CREATEDBY, t.EXPIRATIONTIME as EXPIRATIONDATE, t.priority as PRIORITY, t.STATUS as STATUS, t.PROCESSINSTANCEID as PROCESSINSTANCEID, t.deploymentid as DEPLOYMENTID, t.PROCESSID as PROCESSID from TASK t left join PEOPLEASSIGNMENTS_POTOWNERS po on t.id=po.task_id inner join PROCESSINSTANCELOG p on t.processinstanceid = p.processinstanceid",
        "query-target" : "USER_GROUPS_TASK"
      }
       
      will give the following in my environment:
       
       

      taskid createdon
      34 10/14/21 11:45 AM
      33 10/14/21 11:45 AM
      32 10/14/21 11:45 AM
      31 10/14/21 11:45 AM
      30 10/14/21 11:43 AM
      29 10/14/21 11:43 AM
      3 10/08/21 12:53 PM

       
       
      and I'll get the following with "order-by-clause":"createdon desc":
       
      [bkramer@bkramer bin]$ curl -X POST -u 'rhpamAdmin:rhpamAdmin123!' "http://localhost:8080/kie-server/services/rest/server/queries/definitions/jbpmHumanTasksPO/filtered-data?mapper=UserTasksWithPotOwners&page=0&pageSize=10" -H "accept: application/json" -H "content-type: application/json" -d '{"query-params":[

      {"cond-column":"priority","cond-operator":"EQUALS_TO","cond-values":["0"]}

      ,{"cond-column":"potowner","cond-operator":"EQUALS_TO","cond-values":["PM"]},{"cond-column":"status","cond-operator":"IN","cond-values":["Ready","Reserved","InProgress"]}],"order-by-clause":"createdon desc"}' | grep task-id
          "task-id" : 34,
          "task-id" : 33,
          "task-id" : 32,
          "task-id" : 31,
          "task-id" : 30,
          "task-id" : 29,
          "task-id" : 3,
       
      If I use "order-by-clause":"CREATEDON desc":
       
      [bkramer@bkramer bin]$ curl -X POST -u 'rhpamAdmin:rhpamAdmin123!' "http://localhost:8080/kie-server/services/rest/server/queries/definitions/jbpmHumanTasksPO/filtered-data?mapper=UserTasksWithPotOwners&page=0&pageSize=10" -H "accept: application/json" -H "content-type: application/json" -d '{"query-params":[

      {"cond-column":"priority","cond-operator":"EQUALS_TO","cond-values":["0"]}

      ,{"cond-column":"potowner","cond-operator":"EQUALS_TO","cond-values":["PM"]},{"cond-column":"status","cond-operator":"IN","cond-values":["Ready","Reserved","InProgress"]}],"order-by-clause":"CREATEDON DESC"}' | grep task-id

        "task-id" : 30,
        "task-id" : 34,
        "task-id" : 33,
        "task-id" : 29,
        "task-id" : 3,
        "task-id" : 32,
        "task-id" : 31,
       
      the order is different and not correct.
       
      I also used "order-by" instead of "order-by-clause" with "createdon desc" and "CREATEDON desc" but with this I got the same result in both case but incorrect:
       
      [bkramer@bkramer bin]$ curl -X POST -u 'rhpamAdmin:rhpamAdmin123!' "http://localhost:8080/kie-server/services/rest/server/queries/definitions/jbpmHumanTasksPO/filtered-data?mapper=UserTasksWithPotOwners&page=0&pageSize=10" -H "accept: application/json" -H "content-type: application/json" -d '{"query-params":[

      {"cond-column":"priority","cond-operator":"EQUALS_TO","cond-values":["0"]}

      ,{"cond-column":"potowner","cond-operator":"EQUALS_TO","cond-values":["PM"]},{"cond-column":"status","cond-operator":"IN","cond-values":["Ready","Reserved","InProgress"]}],"order-by":"CREATEDON desc"}' | grep task-id
         "task-id" : 30,
          "task-id" : 34,
          "task-id" : 33,
          "task-id" : 29,
          "task-id" : 3,
          "task-id" : 32,
          "task-id" : 31,I would like t
      [bkramer@bkramer bin]$ curl -X POST -u 'rhpamAdmin:rhpamAdmin123!' "http://localhost:8080/kie-server/services/rest/server/queries/definitions/jbpmHumanTasksPO/filtered-data?mapper=UserTasksWithPotOwners&page=0&pageSize=10" -H "accept: application/json" -H "content-type: application/json" -d '{"query-params":[

      {"cond-column":"priority","cond-operator":"EQUALS_TO","cond-values":["0"]}

      ,{"cond-column":"potowner","cond-operator":"EQUALS_TO","cond-values":["PM"]},{"cond-column":"status","cond-operator":"IN","cond-values":["Ready","Reserved","InProgress"]}],"order-by":"createdon desc"}' | grep task-id
          "task-id" : 30,
          "task-id" : 34,
          "task-id" : 33,
          "task-id" : 29,
          "task-id" : 3,
          "task-id" : 32,
          "task-id" : 31,
       
      Customer is taking these parameters from the public class [QueryResultMapper](https://github.com/kiegroup/jbpm/blob/main/jbpm-services/jbpm-services-api/src/main/java/org/jbpm/services/api/query/QueryResultMapper.java#L90) and in this class the column is in upper case. 
       

            elguardian@gmail.com Enrique González Martínez (Inactive)
            rhn-support-bkramer1 Biljana Kramer
            Antonio Fernandez Alhambra Antonio Fernandez Alhambra (Inactive)
            Antonio Fernandez Alhambra Antonio Fernandez Alhambra (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: