cancel
Showing results for 
Search instead for 
Did you mean: 

problem with ...Like('pattern') methods

ankits
Champ in-the-making
Champ in-the-making
I want to search for the task names using some pattern. but the method taskNameLike("taskName") does not return the result based on the pattern provided. I can see in the HistoricTaskInstance.xml file the query as:

<sql id="selectHistoricTaskInstancesByQueryCriteriaSql">
    from ${prefix}ACT_HI_TASKINST RES
    <if test="processFinished || processUnfinished">
          inner join ${prefix}ACT_HI_PROCINST HPI ON RES.PROC_INST_ID_ = HPI.ID_
    </if>
    <if test="processDefinitionKey != null || processDefinitionName != null">
      inner join ${prefix}ACT_RE_PROCDEF D on RES.PROC_DEF_ID_ = D.ID_
    </if>
    <where>
      .
      .
      .
        <if test="taskNameLike != null">
                and RES.NAME_ like #{taskNameLike}
        </if>
      .
      .
   </where>
</sql>
but in above query no pattern matching characters are used. If it cannot search based on given pattern, what is the point in using <strong>like</strong> operator here.
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
You need to add '%' to your query. Eg %blah% to search for everything with 'blah' in

ankits
Champ in-the-making
Champ in-the-making
thanx for your response, but why not add it to the xml itself…

jbarrez
Star Contributor
Star Contributor
Because sometimes you want to search for '%blah%', but sometimes you only want 'blah%', meaning only the ones starting with 'blah'. Or %blah%somethingelse%. or …

I think you get the picture … not having it fixed is way more flexible.

ankits
Champ in-the-making
Champ in-the-making
ya got it.. thanx..