Hibernate ID策略 與jBPM4.3執行中的異常

最開始在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.3jbpm.execution.hbm.xmlExecutionImpl 類有如下配置:

<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以上的版本即可。

發佈了29 篇原創文章 · 獲贊 6 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章