2006-05-09

将JBPM数据库改为MySQL

其实挺简单的,不知道开始的时候不行,后来看自己代码太乱整理了一下然后就好了,奇怪了 @_@ :

环境就是jbpm的GPD, 新建立个工程后会自动产生一些结构性的文件和目录,把src/config.files下的hibernate.cfg.xml作下修改,大致就类似这个:
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/jbpm
hibernate.connection.username=root
hibernate.connection.password=rootpassword
然后就是设置数据库了,得先找到ddl的脚本,我查了半天,最后终于在jbpm-starter-kit-3.1里找到了,是在/jbpm-db/build/mysql/目录下面的,有个mysql.create.sql,执行它,打开MySQL看就会看到一大堆的表,嗯,这部分工作就算完成了.
然后就是写TestCase,在这之前随便用Designer作个工作流图.

public class JayTestProcess extends TestCase
{
public void testSimplePersistence()
{
JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
ProcessDefinition definition = ProcessDefinition.parseXmlResource("qqq.par/processdefinition.xml");

//do deploy process definition to database :
try
{
jbpmContext.deployProcessDefinition(definition);
}finally
{
jbpmContext.close();
}
}
}

回去再看一下MySQL里面就有数据了,大概就是这么回事吧.还有个问题没解决就是在执行过程中会有WARN 说
22:16:21,638 [main] WARN EhCacheProvider : Could not find configuration [org.jbpm.graph.def.Node]; using defaults.
等等一大堆的找不到configuration,不知道它是不是在找用户自定义的configuration?

No comments: