提交 372cbf1e 编写于 作者: T tombaeyens

ACT-60 fixed some unit tests and added optimistic locking exception

上级 d73ebe5d
......@@ -42,9 +42,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/BoundaryTimerEventTest.java</exclude>
<exclude>**/TaskFormsTest.java</exclude>
<exclude>**/TaskCandidateTest.java</exclude>
<exclude>**/FinancialReportProcessTest.java</exclude>
</excludes>
</configuration>
......
......@@ -36,7 +36,11 @@ public class TaskFormsTest extends ProcessEngineTestCase {
identityService.deleteUser("fozzie");
}
@Deployment(resources = { "VacationRequest.bpmn20.xml", "approve.form", "request.form", "adjustRequest.form" })
@Deployment(resources = {
"org/activiti/examples/taskforms/VacationRequest.bpmn20.xml",
"org/activiti/examples/taskforms/approve.form",
"org/activiti/examples/taskforms/request.form",
"org/activiti/examples/taskforms/adjustRequest.form" })
public void testTaskFormsWithVacationRequestProcess() {
// Get start form
......
......@@ -92,7 +92,6 @@
<configuration>
<excludes>
<exclude>**/HistoricDataServiceImplTest.java</exclude>
<exclude>**/CallActivityAdvancedTest.java</exclude>
</excludes>
</configuration>
</plugin>
......
......@@ -44,14 +44,15 @@ public class DbRuntimeSession implements Session, RuntimeSession {
this.dbSqlSession = CommandContext.getCurrent().getDbSqlSession();
}
@SuppressWarnings("unchecked")
public void deleteProcessInstance(String processInstanceId, String deleteReason) {
ExecutionEntity execution = findExecutionById(processInstanceId);
List<Task> tasks = new TaskQueryImpl()
List<TaskEntity> tasks = (List) new TaskQueryImpl()
.processInstanceId(processInstanceId)
.executeList(CommandContext.getCurrent(), null);
for (Task task: tasks) {
dbSqlSession.delete(TaskEntity.class, task.getId());
for (TaskEntity task: tasks) {
task.delete();
}
execution.deleteCascade(deleteReason);
......
......@@ -345,7 +345,10 @@ public class DbSqlSession implements Session {
throw new ActivitiException("no update statement for "+updatedObject.getClass()+" in the ibatis mapping files");
}
log.fine("updating: "+toString(updatedObject)+"]");
sqlSession.update(updateStatement, updatedObject);
int updatedRecords = sqlSession.update(updateStatement, updatedObject);
if (updatedRecords!=1) {
throw new OptimisticLockingException(toString(updatedObject)+" was updated by another transaction concurrently");
}
}
updatedObjects.clear();
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence.db;
import org.activiti.engine.ActivitiException;
/**
* @author Tom Baeyens
*/
public class OptimisticLockingException extends ActivitiException {
private static final long serialVersionUID = 1L;
public OptimisticLockingException(String message, Throwable cause) {
super(message, cause);
}
public OptimisticLockingException(String message) {
super(message);
}
}
......@@ -14,6 +14,7 @@
<resultMap id="jobResultMap" type="org.activiti.engine.impl.persistence.runtime.JobEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<result property="lockOwner" column="LOCK_OWNER_" jdbcType="VARCHAR" />
<result property="lockExpirationTime" column="LOCK_EXP_TIME_" jdbcType="TIMESTAMP" />
<result property="exclusive" column="EXCLUSIVE_" jdbcType="BOOLEAN" />
......@@ -135,7 +136,7 @@
<update id="updateTimer" parameterType="org.activiti.engine.impl.persistence.runtime.TimerEntity">
update ACT_JOB
<set>
REV= #{revisionNext, jdbcType=INTEGER},
REV_ = #{revisionNext, jdbcType=INTEGER},
LOCK_EXP_TIME_ = #{lockExpirationTime, jdbcType=TIMESTAMP},
LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR},
RETRIES_ = #{retries, jdbcType=INTEGER},
......@@ -143,7 +144,7 @@
DUEDATE_ = #{duedate, jdbcType=TIMESTAMP}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV = #{revision, jdbcType=INTEGER}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<!-- TIMER SELECT -->
......@@ -211,7 +212,7 @@
EXCEPTION_ = #{exception, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV = #{revision, jdbcType=INTEGER}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
</mapper>
......@@ -69,7 +69,7 @@
</select>
<select id="selectExecutionsByQueryCriteria" parameterType="org.activiti.engine.impl.ExecutionQueryImpl" resultMap="executionResultMap">
select *
select E.*
<include refid="selectExecutionsByQueryCriteriaSql"/>
<if test="orderBy != null">
order by #{orderBy}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册