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

MySQL 的更改如下:
   <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
   <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
   <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/onlineas</property>
   <property name="hibernate.connection.username">root</property>
   <property name="hibernate.connection.password">123456</property>

运行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即可,<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2022-01-11
  • 2021-08-01
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2021-05-25
  • 2021-11-16
  • 2021-09-03
  • 2021-12-29
相关资源
相似解决方案