最开始在jBPM4.3执行过程中老是遇到 SQL异常,提示“无效数字”。仔细跟踪发现,是因为Hibernate ID策略与jBPM4.3中的一些Model中字段名称造成的。在Hibernate Reference 中(14.5. Refering to identifier property)有如下描述:
Note: this has changed significantly starting in version 3.2.2. In previous versions, id always referred to the identifier property no matter what its actual name. A ramification of that decision was that non-identifier properties named id could never be referenced in Hibernate queries.
而在jBPM4.3的jbpm.execution.hbm.xml中ExecutionImpl 类有如下配置:
<class name="ExecutionImpl"
table="JBPM4_EXECUTION"
discriminator-value="pvm">
<id name="dbid" column="DBID_">
<generator class="assigned" />
</id>
……
<property name="id" column="ID_" unique="true" />
检查发现,项目中使用的Hibernate版本是3.2.0。这就是导致错误的原因了,在ExecutionImpl类中对id访问的时候,始终都是访问的DBID_列。解决方式是将hibernate换成3.2.2以上的版本即可。