Hi, I recently use HistoryService to get variables of a Execution, with following code
final List<HistoricVariableInstance> varlist =
historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId)
.executionId(executionId).list();
and I got SQL Syntax Error,
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT RES.*
FROM ACT_HI_VARINST RES
WHERE RES.PROC_INST_ID_ = ?
RES
.EXECUTION_ID_ = ? ORDER BY RES.ID_ ASC
LIMIT ? OFFSET ? "; SQL statement:
select RES.*
from ACT_HI_VARINST RES
WHERE RES.PROC_INST_ID_ = ?
RES.EXECUTION_ID_ = ?
order by RES.ID_ asc
LIMIT ? OFFSET ? [42000-181]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.getSyntaxError(DbException.java:191)
at org.h2.command.Parser.getSyntaxError(Parser.java:518)
at org.h2.command.Parser.prepareCommand(Parser.java:245)
at org.h2.engine.Session.prepareLocal(Session.java:446)
at org.h2.engine.Session.prepareCommand(Session.java:388)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1189)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:72)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:277)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:239)
at com.sun.proxy.$Proxy6.prepareStatement(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:75)
at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:85)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:57)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:73)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
… 17 more
as exception described, the Select statement missing a 'AND' between RES.PROC_INST_ID_
and RES.EXECUTION_ID_
. and Sqlmap also don't have 'and'
<sql id="selectHistoricVariableInstanceByQueryCriteriaSql">
from ${prefix}ACT_HI_VARINST RES
<where>
<if test="id != null">
RES.ID_ = #{id}
</if>
<if test="processInstanceId != null">
RES.PROC_INST_ID_ = #{processInstanceId}
</if>
<if test="executionId != null">
RES.EXECUTION_ID_ = #{executionId}
</if>
<if test="taskId != null">
and RES.TASK_ID_ = #{taskId}
</if>
<if test="excludeTaskRelated">
and RES.TASK_ID_ is NULL
</if>
does this mean my usage of HistoryService is incorrect? only one of processInstancdId and executionId is required?what's difference between processInstance and execution? seems them are the same in most case=========My Activiti Version: 5.18.0MyBatis Version: 3.2.5