Make a TaskQuery resuable
-------------------------
Key: JBPM-2538
URL:
https://jira.jboss.org/jira/browse/JBPM-2538
Project: jBPM
Issue Type: Feature Request
Security Level: Public (Everyone can see)
Affects Versions: jBPM 4.1
Reporter: Joram Barrez
Priority: Minor
Fix For: jBPM 4.3
Queries can't be reused:
TaskQuery openTasksQuery = taskService.createTaskQuery().state(Task.STATE_OPEN);
List<Task> openTasks = openTasksQuery.list();
openTasks = openTasksQuery.list();
The first time list() is called, the HQL query that is produced is fine:
select task from org.jbpm.pvm.internal.task.TaskImpl as task where task.state =
'open'
The second time however, the query is wrong:
select task from org.jbpm.pvm.internal.task.TaskImpl as task and task.state =
'open'
This due to the fact that in AbstractQuery, a boolean is remembered for the where clause:
rotected void appendWhereClause(String whereClause, StringBuilder hql) {
if (isWhereAdded) {
hql.append(" and ");
} else {
isWhereAdded = true;
hql.append("where ");
}
hql.append(whereClause);
}
In the second call, the 'isWhereAdded' boolean is set to true (due to the first
call), which leads to not using the where clause and resulting in a wrong query.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira