AnsweredAssumed Answered

Query an array variable

Question asked by javialfresco on Jan 29, 2015
Latest reply on Feb 9, 2015 by martin.grofcik
I read about why variables of type ByteArray cannot be queried and I understand that Blobs cannot be queried in the where-clause but I'm not sure what could be the better approach for my situation:

- I have an  Array variable, lets say: validators = ["a","b","c"] stored in my activiti process

- I want this variable to be an Array because I'm adding - removing elements to this Array with some taskListeners and finally this is the
collection used as the input for a multiinstance task

- Somewhere (before multiinstance) in my business logic I have to search for all the processes with a variable "validators" that contains element "b" and I cannot query this variable because validators array is stored as a ByteArray variable.

Nowadays I'm querying for all process that the variable "validators" is not null (
runtimeService.createProcessInstanceQuery().variableValueLike("validators","%b%")
) and doing some java-processing to get what I'm looking for but this is not an efficient way to do this kind of querys.

I can change this array variable to a String variable and store it like "a,b,c" and then do a variableLike query:
runtimeService.createProcessInstanceQuery().variableValueLike("validators","%b%")
, but in this case I have to do StringToArray and ArrayToString transformations everywhere I need to deal with my validators array.


I cannot find any other way to query my array variable, ¿Am I wrong? ¿Is there a better way to do this kinds of query?

Thanks!

Outcomes