@Override
 public long executeCount(CommandContext commandContext) {
   ensureVariablesInitialized();
   checkQueryOk();
   return commandContext
       .getHistoricTaskInstanceEntityManager()
       .findHistoricTaskInstanceCountByQueryCriteria(this);
 }
 protected void ensureVariablesInitialized() {
   VariableTypes types = Context.getProcessEngineConfiguration().getVariableTypes();
   for (QueryVariableValue var : queryVariableValues) {
     var.initialize(types);
   }
   if (orQueryObject != null) {
     orQueryObject.ensureVariablesInitialized();
   }
 }
 @Override
 public List<HistoricTaskInstance> executeList(CommandContext commandContext, Page page) {
   ensureVariablesInitialized();
   checkQueryOk();
   if (includeTaskLocalVariables || includeProcessVariables) {
     return commandContext
         .getHistoricTaskInstanceEntityManager()
         .findHistoricTaskInstancesAndVariablesByQueryCriteria(this);
   } else {
     return commandContext
         .getHistoricTaskInstanceEntityManager()
         .findHistoricTaskInstancesByQueryCriteria(this);
   }
 }