2 Replies Latest reply on Mar 15, 2007 12:29 PM by Harald Strack

    Searching tasks by task variables (hibernated business objec

    Harald Strack Newbie

      Hi,

      I am trying to figure out the right HQL for finding TaskInstances that have an hibernated business object assigned.

      I know how to find TaskInstances with simple String variables assigned:

      select taskinstance from TaskInstance taskinstance join taskinstance.variableInstances as variable where variable.name = :varname and variable.value =:varvalue and taskinstance.name = 'Change Provider Request' and taskinstance.isOpen = true
      


      Now I have a businessobject called "Domain" assigned to the task and I am trying to find it like this:

      select taskinstance from TaskInstance taskinstance join taskinstance.variableInstances as variable, Domain d where variable.name = :varname and d.name =:varvalue and taskinstance.name = 'Change Provider Request'
      


      Does not work (there is no join of the Domain and the TaskInstance)... And my HQL is so bad, that I cannot figure out how to do it correctly!

      Any help is greatly appreciated!

      br

      Harald Strack

        • 1. Re: Searching tasks by task variables (hibernated business o
          Ronald van Kuijk Master

          did you try the hibernate ide to help you? it is good....

          • 2. Re: Searching tasks by task variables (hibernated business o
            Harald Strack Newbie

            Hi,

            OK, I did with the Hibernate Tools. It was a pain, to install them properly (I am also using spring). But I found the query. Here it is, for interested people:

            select taskinstance from Domain as dom,
             TaskInstance taskinstance,
             HibernateLongInstance as hibernatelonginstance
            where
             taskinstance.name = 'Change Provider Request'
             and taskinstance.isOpen = true
             and hibernatelonginstance.id =taskinstance.variableInstances.id
             and hibernatelonginstance.name = 'domain'
             and hibernatelonginstance.value.id = dom.id
             and dom.name = :varvalue
            


            varvalue: a domain Name (class Domain has a "name" field)
            


            This query searches a TaskInstance that has a "Domain" object assigned.

            Take care: it may only work with jbpm >= 3.1.4

            The TaskInstance is created like this:

             <task-node name="Task DomBla task">
             <task name="Task DomBla" swimlane="swimlane1">
             <controller>
             <variable name="domain" access="read"></variable>
             <variable name="approve" access="read,write,required"></variable>
             </controller>
             </task>
             <transition name="" to="isApproved"></transition>
             </task-node>
            


            This way you may also list some BusinessObjects with their assigned tasks (if you skip the last line of the query)...

            When I executed the query in the hibernate console (eclipse) I got a result and eclipse was getting stuck on 100% CPU for quite a while (tested on freebsd, linux and windows). Seems to be a bug in the hibernate console - however - it is beta software.

            It may help anyone who neither has a clue about HQL...

            Greetings

            Harry