4 Replies Latest reply on Feb 7, 2012 9:29 AM by Israel Elías Salgado

    extending taskquery

    Sofie Ravyts Newbie

      I'm trying to extend TaskQueryImpl so I can add my own domain model search criteria.

      I first started out by creating a new query impl class extending AbstractQuery. But then I was thinking that it would be better to extend TaskQueryImpl and append my search criteria to the hql() generated by this class (this way, changes on the jbpm task tables won't cause my queries to error because I get the changes made to TaskQueryImpl for free.)

      But ...

      in the hql() method of TaskQueryImpl appendOrderByClause(hql) is called. So I can't append other search criteria after calling super.hql()... Couldn't it be possible to call the appendOrderByClause() from the AbstractQuery -> execute method after calling hql()? Ok, maybe the hql() method name is not really a good method name anymore in this case because the full hql is not generated here ...
      But it would make the queries a lot more extendable!

      What do you think?

      Wk,
      Sofie

        • 1. Re: extending taskquery
          Ronald van Kuijk Master

          what is the advantage of combining it into one query compared to all the hassle you get into? The number and performance of the queries?

          • 2. Re: extending taskquery
            Sofie Ravyts Newbie

            This my situation:

            I have a processInstance which has a variable "objectId" which points to an id of an object in our domain model.

            Now I want to query for all tasks for which the object's name referenced by "objectId" in the variables is a given value.

            Any suggestions on how to do this without using a query on both our object's table and the task/variables table?
            Iterating over all tasks, getting the objectId from the variables, quering the object and seeing if the name is what we are looking for, seems not to be the best way, don't you agree?
            Maybe I'm overlooking some other solution?

            Wkr,
            Sofie

            • 3. Re: extending taskquery
              Ronald van Kuijk Master

              Is a processinstance related to a unique objectID? If so use the businesskey. You can retrieve the processinstance by key and retrieve all tasks related to this instance

              • 4. Re: extending taskquery
                Israel Elías Salgado Newbie

                I have the same problem , I want to use appendOrderByClause(hql), but never execute this code in my program, I  want to do my self method, where I can execute appendOrderByClause(hql) for ordered the group tasks correctly.

                 

                Does anyone know how?

                 

                 

                Thanks.