AnsweredAssumed Answered

Sort problem on activi historic table (sort by id)

Question asked by lestat86 on Jul 1, 2015
Latest reply on Jul 1, 2015 by lestat86
Hi everyone,

I recently discovered what might be a bug in the activity historic table (act_hi_actinst). In my application i need to display the last activity executed by a certain process, so what i've done for the past month is using this code to get it:


getHistoryService().
createHistoricActivityInstanceQuery().
processInstanceId(processId).
orderByHistoricActivityInstanceId().
desc().
list().
get(0).
getActivityName();


It worked fine until now, when the method gives me not the last but the second to last activity. I noticed that it is because the id of the very last is 100036, while the second to last is 99856. This case was replicated several times, and i think that it behaves the way it does because the id field is a varchar(64), so the lexicographic sort kicks in.

Why use a varchar instead of a serial then? Is this something done on purpose or a mistake?

Thanks a lot

Alberto



Outcomes