问题如下:
九月 30, 2013 2:24:14 下午 org.jbpm.internal.log.Jdk14Log info 信息: exception while executing command org.jbpm.pvm.internal.cmd.CheckDbCmd@2bfb3f37 org.jbpm.api.JbpmException: no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the install tool. at org.jbpm.pvm.internal.cmd.CheckDbCmd.execute(CheckDbCmd.java:50) at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42) at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:49) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40) at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56) at org.jbpm.pvm.internal.processengine.ProcessEngineImpl.checkDb(ProcessEngineImpl.java:152) at org.jbpm.pvm.internal.processengine.SpringProcessEngine.create(SpringProcessEngine.java:70) at org.jbpm.pvm.internal.cfg.ConfigurationImpl.buildProcessEngine(ConfigurationImpl.java:90) at org.jbpm.pvm.internal.processengine.SpringHelper.createProcessEngine(SpringHelper.java:50) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601)
最近将jbpm4.4项目用的数据库由sqlserver改成oracle 11g的,在配置hibernate时候出现了上面的错误,在网上没有查到原因,但是根据打印的错误仔细分析后,猜测可能是数据库方言的问题,因为之前将sqlserver数据库改成mysql时候有过类似的问题,只不过当时没有记录下来,现在记录一下,以防后用。
hibernate连接不同数据库有不同的方言,下面列出来如下:
mysql的方言:
org.hibernate.dialect.MySQLDialect
sqlserver的方言:
org.hibernate.dialect.SQLServerDialect
oracle 的方言:
org.hibernate.dialect.OracleDialect
但是配置好相应数据库的方言后,项目就可以正常运行了,但是有一个地方要注意的是,在java项目中执行数据库的增删改查时候有时候数据库字段类型和java的数据类型转换会出现问题,这时候就要重新方言了,下面我列出重写mysql和sqlserver方言的例子:
也可以参考我之前写的帖子: http://kevin12.iteye.com/blog/1815460
对于mysql的:
package com.sense.workflow.util; import java.sql.Types; import org.hibernate.Hibernate; import org.hibernate.dialect.MySQLInnoDBDialect; /** * mysql注册类型映射 * @author lujinyong * */ public class ExtMySQL5Dialect extends MySQLInnoDBDialect{ public ExtMySQL5Dialect(){ super(); this.registerHibernateType(Types.LONGVARCHAR, Hibernate.STRING.getName()); } }
对于sqlserver的:
package com.sense.workflow.util; import java.sql.Types; import org.hibernate.Hibernate; import org.hibernate.dialect.SQLServerDialect; /** * sqlserver2008注册类型映射 * @author lujinyong * */ public class SqlServer2008Dialect extends SQLServerDialect{ public SqlServer2008Dialect() { super(); registerHibernateType(Types.CHAR, Hibernate.STRING.getName()); registerHibernateType(Types.VARCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.LONGVARCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.DECIMAL, Hibernate.DOUBLE.getName()); registerHibernateType(Types.LONGVARCHAR, Hibernate.TEXT.getName()); } }
在hibernate中的引用如下:
com.sense.workflow.util.ExtMySQL5Dialect
com.sense.workflow.util.SqlServer2008Dialect
oracle的暂时还没有写,以后添加上。
链接地址: http://kevin12.iteye.com/blog/1949491