cancel
Showing results for 
Search instead for 
Did you mean: 

taskService.createTaskQuery().orderByExecutionId().desc().list() -invalid query getting created

devesh
Champ in-the-making
Champ in-the-making
Activiti Engine : 5.19.0

Usage : taskService.createTaskQuery().orderByExecutionId().desc().list()  ;

Database MySQL :

Logs :
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by RES.EXECUTION_ID_ desc 
    LIMIT 2147483647 OFFSET 0' at line 15
### The error may exist in org/activiti/db/mapping/entity/Task.xml
### The error may involve org.activiti.engine.impl.persistence.entity.TaskEntity.selectTaskByQueryCriteria-Inline
### The error occurred while setting parameters
### SQL: select distinct RES.*              from ACT_RU_TASK RES                                                                     order by  order by RES.EXECUTION_ID_ desc       LIMIT ? OFFSET ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by RES.EXECUTION_ID_ desc 
    LIMIT 2147483647 OFFSET 0' at line 15
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
   at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:436)
   at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:427)
   at org.activiti.engine.impl.persistence.entity.TaskEntityManager.findTasksByQueryCriteria(TaskEntityManager.java:135)
   at org.activiti.engine.impl.TaskQueryImpl.executeList(TaskQueryImpl.java:1230)
   at org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:164)
   at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
7 REPLIES 7

vasile_dirla
Star Contributor
Star Contributor
Hi, did you upgrade any library (for example mybatis) or this happens with the out of the box version ?

devesh
Champ in-the-making
Champ in-the-making
I have just started with activiti and not updated any library.
Mybatis version I have used : 3.3

The Sample code I am using is :
<java>
TaskService taskService = processEngine.getTaskService();
  ManagementService managementService = processEngine.getManagementService();
  IdentityService identityService = processEngine.getIdentityService();
  HistoryService historyService = processEngine.getHistoryService();
  FormService formService = processEngine.getFormService();
  System.out.println(identityService);

  System.out.println("Number of process definitions : " + repositoryService.createProcessDefinitionQuery().count());
  System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
  // runtimeService.startProcessInstanceByKey("holidayVacationRequest");
  System.out.println("Number of tasks after process start: " + taskService.createTaskQuery().count());

  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("employeeName", "Kermit");
  variables.put("numberOfDays", new Integer(4));
  variables.put("vacationMotivation", "I'm really tired!");

  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holidayVacationRequest", variables);

  List<Task> tasks = taskService.createTaskQuery().orderByExecutionId().desc().list();
  for (Task task : tasks) {
   System.out.println(task);
  }
</java>

Output I am getting as :

org.activiti.engine.impl.IdentityServiceImpl@3542162a
Number of process definitions : 11
Number of tasks : 90
Number of tasks after process start: 90

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by RES.EXECUTION_ID_ desc 
    LIMIT 2147483647 OFFSET 0' at line 15
### The error may exist in org/activiti/db/mapping/entity/Task.xml
### The error may involve org.activiti.engine.impl.persistence.entity.TaskEntity.selectTaskByQueryCriteria-Inline
### The error occurred while setting parameters

devesh
Champ in-the-making
Champ in-the-making
Just few points to highlight, 
1) The order by clause its repeated
2) The activiti-explorer is using mybatis 3.2 version and the out of the box version that I have deployed is using mybatis 3.3 .
3) The code works if I downgrade the mybatis version to 3.2 for out of the box activiti engine .

jbarrez
Star Contributor
Star Contributor
@Devesh: correct.

Mybatis has been upgraded to 3.3 on master: https://github.com/Activiti/Activiti/commit/647e92b667e98e4cf3d063dd9ff05952a3e87e13

devesh
Champ in-the-making
Champ in-the-making
Hi,
  Thank you for updating the mybatis version, saved my research and time to use the JBOSS Drools .
   Would I be able to download this version (5.20-Snapshot) from http://activiti.org/download.html , or I need to build from git hub.
   I searched on http://activiti.org/download.html but the 5.20-Snapshot is not present for download.

jbarrez
Star Contributor
Star Contributor
No, snapshots are not published. You will need to build from source after cloning the root repository (i think a 'mvn -Pcheck -DskipTests clean install' will give you the jars you want)

devesh
Champ in-the-making
Champ in-the-making
Thank You ,
Will build it from source and would be ready for version 6 with the current changes to be present in the upcoming version.