cancel
Showing results for 
Search instead for 
Did you mean: 

processVariableValueLike ineffective - Why ?

ugo1
Champ in-the-making
Champ in-the-making
I can get normally all my tasks included one which contains this variable:

{clientOrderId=1450, …}

when I do:

taskService.createTaskQuery().includeProcessVariables().list()

But when I do :

taskService.createTaskQuery().processVariableValueLike("clientOrderId", "1450").singleResult()

I get a null.

Is it explainable, or am I doing something wrong ?
6 REPLIES 6

ugo1
Champ in-the-making
Champ in-the-making
I finally found the problem.

It seems that because I stored my clientOrderId variable as a Long, then the Activiti engine is unable to do the comparison with a String (which is normal). But then my question is, why the method processVariableValueEquals takes a String for the value parameter, instead of an Object ?

jbarrez
Star Contributor
Star Contributor
It does:

<code>
/**
   * Only select process instances which have a global variable with the given value. The type
   * of variable is determined based on the value, using types configured in
   * {@link ProcessEngineConfiguration#getVariableTypes()}.
   * Byte-arrays and {@link Serializable} objects (which are not primitive type wrappers)
   * are not supported.
   * @param name name of the variable, cannot be null.
   */
  ProcessInstanceQuery variableValueEquals(String name, Object value);
</code>

The method you used, has a 'like' in it. You can only do a like with a string, not with a number.

cosminradu_vasi
Champ in-the-making
Champ in-the-making
Is this operation - processVariableValueLike- case sensitive? I can't find this information in the documentation. We just upgrade in a project to 5.14 because this method wasn't in 5.11, but after a smoke test it seems is case sensitive? Are we missing something or it's just a limitation from activiti 5.14?

Regards,

jbarrez
Star Contributor
Star Contributor
It is case sensitive if your database has case sensitive string comparison. Which most databases have.

Ok,,,I was hopping you guys would have some toLowerCase stuff, because the equals restriction isn't case sensitive and I believe this is what you've done here.

So the collation "bin" from the "act_ru_variables" table is the problem. If we change the collation to something like "utf8_general_ci" will we broke something really bad? Is there a particular reason for "utf8_bin" collation?

frederikherema1
Star Contributor
Star Contributor
Since strings that differ in case aren't exaclty the same, we opted for the case-sensitive approach. Offcoruse, depending on your DB configuration, LIKEs kan work case-insensitive as well. We're using the utf8_bin for that reason (to make our LIKE-unit-tests run on all DB's being case-sensitive). It's perfectly fine, however, to change that. Activiti does not "count" on this behaviour, so it's safe to alter the collation.