cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Sql query and Serialize variable

nik10_mah
Champ in-the-making
Champ in-the-making
Hi,

I am passing a serialized bean named WfeBean( which contains entityId and statusId as fields) as process variable. And it seems it stores the bean in act_ge_bytearray table. Now i want  to create a query which fetches all the entityId of the tasks assigned to a user.
I am created a query as described in this blog http://www.jorambarrez.be/blog/2014/01/17/execute-custom-sql-in-activiti/.
Tis is the query i have made.
SELECT variable.NAME_ as variableValue FROM ACT_RU_VARIABLE variable",
   "inner join ACT_RU_TASK task on variable.PROC_INST_ID_ = task.PROC_INST_ID_",
   "where task.ASSIGNEE_ = #{assignee}" })



Now when i try to get the  wfeBean from result Map it gives me wfeBEan as string ans when i try to cast it it throws nullpointer exception.

So how can i get this object. Can i use native query for this.?


3 REPLIES 3

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Nikhil,

I would recommend to use taskService.createTaskQuery to get a list of tasks assigned to the user. From the fetched task list you can get task ids.


taskService.createTaskQuery().taskAssignee(asigneee).list();

Regards
Martin

nik10_mah
Champ in-the-making
Champ in-the-making
Actually i wanted the list of entityIds in WfeBean as mentioned in question. If i fetch tasks the i would have to iterate through all the tasks to the entityIds so i am trying to skip this loop. And fetch the entity Ids only.

I have able to fetch the list of WfeBean using following query:-

<java>SELECT bytear.NAME_ as name, bytear.bytes_ as value from ACT_GE_BYTEARRAY bytear
   inner join ACT_RU_VARIABLE variable on variable.bytearray_id_ = bytear.id_
   inner join ACT_RU_TASK task on task.PROC_INST_ID_ = variable.PROC_INST_ID_
   where task.ASSIGNEE_ = '1'</java>

But what i want is list of entityIds which is an Integer field  of WfeBEan.

jbarrez
Star Contributor
Star Contributor
You can't, as the bean is serialized as bytes. There is no sql query that allows to do that