---
title: "JBPM报错Cannot delete or update a parent row"
author: "zwt2001267"
date: "2012-07-04T15:44:29Z"
tags: []
categories: ["开源软件"]
slug: "jbpm-cannot-delete-or-update-a-parent-row"
draft: false
lastmod: "2012-07-04T15:44:29Z"
id: 1576569
url: "https://hbzwt.iteye.com/blog/1576569"
---

转：[http://www.cnblogs.com/08mse/archive/2010/03/17/1688221.html](http://www.cnblogs.com/08mse/archive/2010/03/17/1688221.html)

 

首先，分析配置文件hibernate.cfg.xml的内容，其中在默认设置是用 HSQL（开源的数据库），这是一个内存数据库，这种内存数据库用来代替项目实际所用的数据库来做单元测试挺不错的。不过在我们的真实开发中，还是使用oracle等。

MySQL 的更改如下：  
   &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;  
   &lt;property name="hibernate.connection.driver\_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;  
   &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/onlineas&lt;/property&gt;  
   &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;  
   &lt;property name="hibernate.connection.password"&gt;123456&lt;/property&gt;

运行junit测试，抛异常  
07:48:16,655 INF | \[DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd@8a2023  
org.hibernate.exception.ConstraintViolationException: could not delete: \[org.jbpm.pvm.internal.model.ExecutionImpl#10]

....

Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (\`onlineas/jbpm4\_execution\`, CONSTRAINT \`FK\_EXEC\_INSTANCE\` FOREIGN KEY (\`INSTANCE\_\`) REFERENCES \`jbpm4\_execution\` (\`DBID\_\`))

 

解决办法：修改dialect即可，&lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/property&gt;