`
xyz20003
  • 浏览: 289831 次
  • 性别: Icon_minigender_1
  • 来自: 唐山
社区版块
存档分类
最新评论

寻求重现jbpm4.3中executionId映射错误的场景

阅读更多

目前测试的结果是hibernate-3.2.1.ga以及之前的版本下,都会出现dbid和id混淆的问题

hibernate-3.2.2.ga以及之后的版本下就不存在问题了。


自从研究jbpm4以后,经常碰到一个莫名其妙的问题,问题描述起来很简单,就是调用executionService.findExecutionById()时,执行的sql语句应该是
select * from JBPM4_EXECUTION where id_=?

但很多人确说,他们的环境里,实际执行的sql是
select * from JBPM4_EXECUTION where dbid_=?

实际上JBPM4_EXECUTION表的主键是dbid_,id_只是一个拥有唯一索引的列。在jbpm4.execution.hbm.xml中,写明了映射的sql语句是
  <query name="findExecutionById">
    <![CDATA[
     select execution
     from org.jbpm.pvm.internal.model.ExecutionImpl as execution
     where execution.id = :id
    ]]>
  </query>

本来不可能出现的问题,一而再,再而三的被人遇到,就说明这是个大问题了,可惜的是,虽然这个问题被很多人碰到,但是直到现在也没人可以为我提供一个可以重现问题场景的testcase。对自己问题描述的最清楚的人也只是说自己用了spring和jbpm4整合,其他就什么都没有了。

因此我诚挚的向遇到此类问题的人征询测试场景,附件中提供了一个配置好的spring整合jbpm4的测试用例,希望有人能够在此基础上重现这个问题。多谢了。

目前在杭州做项目,如果离杭州这边近的同志遇到这类问题,请直接call me,周六日我可以直接跑过去调试。再次多谢。
分享到:
评论
6 楼 xyz20003 2010-04-27  
多谢xinjunhu澄清了这个问题,这个问题终于算告一段落了,以后再有人遇到这个问题,我会建议他使用jbpm4自带的hibernate3.jar的,多谢。
5 楼 xijunhu 2010-04-27  
问题解决了
果然是hibernate的问题。
我先导入我工程项目的包,然后导入jbpm4下的包,就有这个问题,如果我先导入jbpm4下的包,再导入工程下的包就有问题,查了一下原来是hibernate的问题,用jbpm4下的hibernate包没有这个问题,用了hibernate3.jar这个包就会有这个问题。
谢谢xyz20003
4 楼 xyz20003 2010-04-27  
使用xinjunhu提供的代码进行测试,依然没有出现问题。修整后的测试用例如下。

再次呼吁:
如果大家不会用maven2,或者不愿意在以提供的maven2项目上重现场景,那么请提供一个完整的,包含配置,包含依赖信息的,可以重现错误场景的项目,如果使用了外部数据库,请提供外部数据库的配置以及对应版本号。谢谢。
package test;

import org.springframework.context.support.*;
import junit.framework.*;
import org.jbpm.api.*;
import org.jbpm.api.task.*;
import java.util.*;

public class JbpmTest extends TestCase {


    public void testJbpm() {
        flowStart("Lingo", "dbid");
    }

    public void flowStart(String userId,String flowId){
        ClassPathXmlApplicationContext applicationContext
            = new ClassPathXmlApplicationContext("applicationContext.xml");
        applicationContext.start();

        ProcessEngine processEngine = (ProcessEngine)applicationContext.getBean("processEngine");
        RepositoryService repositoryService = processEngine.getRepositoryService();

        String deploymentDbid = repositoryService.createDeployment()
                                                 .addResourceFromClasspath("jpdl/dbid.jpdl.xml")
                                                 .deploy();
        ExecutionService executionService = processEngine.getExecutionService();

        ProcessInstance processInstance = executionService.startProcessInstanceByKey(flowId);

        TaskService taskService = processEngine.getTaskService();
        String id = processInstance.getId();
        List<Task> taskList = taskService.findPersonalTasks(userId);
        Task task = taskList.get(0);

        taskService.completeTask(task.getId());

        Execution execution = executionService.findExecutionById(task.getExecutionId());
        assertNull(execution);
    }
}


3 楼 xyz20003 2010-04-27  
多谢,我这就测试一下。
2 楼 xijunhu 2010-04-27  
不好意思代码有点乱
public class JbpmTest{
	public static void main(String[] args)  {
		JbpmTest test = new JbpmTest();
		// 启动流程
		test.flowStart("1","leave","0002");
        
    }
// 发起流程
public void flowStart(String userId,String flowId,String getvalue){
		 ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
	        applicationContext.start();
	        
	        ProcessEngine processEngine = (ProcessEngine)applicationContext.getBean("processEngine");
	        ExecutionService executionService = processEngine.getExecutionService();
	        
	    ProcessInstance processInstance = executionService.startProcessInstanceByKey(flowId);

	    TaskService taskService = processEngine.getTaskService();
	    String id = processInstance.getId();
	    List<Task> taskList = taskService.findPersonalTasks("johndoe");
	    Task task = taskList.get(0);
	    
        taskService.completeTask(task.getId());

        Execution execution = executionService.findExecutionById(task.getExecutionId());

	   
	}


配置文件差不多。
1 楼 xijunhu 2010-04-27  
我想应该跟我写的测试类有关系,发给你看看
public class JbpmTest{
	public static void main(String[] args)  {
		JbpmTest test = new JbpmTest();
		// 启动流程
		test.flowStart("1","leave","0002");
        
    }
// 发起流程
	public void flowStart(String userId,String flowId,String getvalue){
		 ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
	        applicationContext.start();
	      ProcessEngine processEngine = (ProcessEngine)applicationContext.getBean("processEngine");
		Map<String, Object> variables = new HashMap<String, Object>();
		processEngine = new Configuration().buildProcessEngine();
		ExecutionService executionService = processEngine.getExecutionService();
		RepositoryService repositoryService=processEngine.getRepositoryService();
	    ProcessInstance processInstance = executionService.startProcessInstanceByKey(flowId, variables);

	    TaskService taskService = processEngine.getTaskService();
	    String id = processInstance.getId();
	    List<Task> taskList = taskService.findPersonalTasks("johndoe");
	    Task task = taskList.get(0);
	    
        
        Execution execution = executionService.findExecutionById(task.getExecutionId());

	   
	}
}

相关推荐

Global site tag (gtag.js) - Google Analytics