3 Replies Latest reply on Apr 25, 2011 7:14 AM by whizkid.samrat

    HQL activity - parameters with EL evaluated values

    jimmyb82

      Hi,

       

      I've been searching around the documentation, tutorials and forums (for two days) to try to understand how I specify parameters to the HQL activity where the value is defined in the execution context.

      I'm using jBPM 4.4 and JBoss EAP 5.0.

      I've tried to specify my HQL node in various fashions bearing in mind there is a executionContext var called invoiceId and it is a Long: -

       

      {code:xml}

         <hql name="Check invoice" g="258,162,117,52" var="invoice" unique="true">

            <query>from Invoice i where i.invoiceId = :invoiceId</query>

                <parameters>

                   <string name="invoiceId" value="#{invoiceId}" />

               </parameters>

            <transition name="Check paid" to="Paid?" g="-62,-4"/>

         </hql>

      {code}

       

      This tries to pass the text as a String with the value "#{invoiceId}"

      If i try to do this with a <long /> then it won't even deploy my process.

      It seemed like i should use a reference as follows: -

       

       

      {code:xml}

         <hql name="Check invoice" g="258,162,117,52" var="invoice" unique="true">

            <query>from Invoice i where i.invoiceId = :invoiceId</query>

                <parameters>

                   <ref object="invoiceId" />

                </parameters>

            <transition name="Check paid" to="Paid?" g="-62,-4"/>

         </hql>

      {code}

       

       

      but this fails because org.jbpm.jpdl.internal.activity.HQLActivity uses the set named parameter methods and there is no way to pass anonymous parameters. It is an anonymous parameter because the ReferenceDescriptor class returns null for getName() and there is no way to specify a name for <ref /> under the http://jbpm.org/4.4/jpdl namespace.

       

      According to this feature request https://jira.jboss.org/browse/JBPM-2279 we should be able to use EL but there is no reference in the documentation as to how.

       

      Can anyone help?

       

      P.S sorry if this comes out badly formatted, it's my first post.

       

      James

        • 1. Re: HQL activity - parameters with EL evaluated values
          jimmyb82

          It's seem's I've managed to answer my own question! (which always seems to be the way when I finally resort to asking a forum)

          I needed to specify the query as follows: -

           

          {code:xml}

             <hql name="Check invoice" var="invoice" unique="true">       <query>from Invoice i where i.invoiceId = :invoiceId</query>       <parameters>          <object name="invoiceId" expr="#{invoiceId}" />        </parameters>       <transition name="Check paid" to="Paid?" g="-62,-4"/>    </hql>

          {code}

           

          Where I failed in my initial attempts at this is that the shipped jpdl-4.4.xsd doesn't allow the attribute "name" on the element object thus my OCD refused to allow me to try entering a name.

          This must mean that the XSD isn't used at runtime to parse the XML otherwise how does it work?

          Unless there is a different copy of the XSD being used at runtime to the one shipped in the distro maybe?

          Should I submit a feature request for a documentation update and/or a bug for the XSD?

          AbstractDescriptor defines "name" as a field so anything extending that should be able to use a name safely.

          • 2. HQL activity - parameters with EL evaluated values
            whizkid.samrat

            James thanks for the solution !

            • 3. HQL activity - parameters with EL evaluated values
              whizkid.samrat

              problem again ..

               

              when I use Jame's solution I get

               

              Not all named parameters have been set: [reqID] [update ORION_LMS_LEAVE_REQ set FINAL_STATUS='approved' where LEAVE_REQ_ID = :reqID]

               

              my xml is like

              <sql g="381,560,129,52" name="CleanupOnApproval" var="approvalQ">

                    <query>update ORION_LMS_LEAVE_REQ set FINAL_STATUS='approved' where LEAVE_REQ_ID = :reqID</query>

                    <parameters><object name="reqID" expr="#{requestId}"/></parameters>

                    <transition g="-102,-11" name="sendApprovalMail" to="sendApprovalMail"/>

                 </sql>

               

              The problem <object> doesnot have a parameter "name" still stands.

               

              Help ..