jbpm Cannot delete or update a parent row: a foreign key constraint fails

打算删除数据,出现错误

Cannot delete or update a parent row: a foreign key constraint fails (`oa`.`application`, CONSTRAINT `FKC00DAD305FBE03CF` FOREIGN KEY (`applicationTemplateId`) REFERENCES `applicationtemplate` (`id`))
FreeMarker template error!
Method public java.lang.String org.hibernate.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on org.hibernate.exception.ConstraintViolationException: could not execute update query
The problematic instruction:
----------
==> ${msg[0]} [on line 68, column 29 in org/apache/struts2/dispatcher/error.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on org.hibernate.exception.ConstraintViolationException: could not execute update query

原因是

如果是MySQL,方言一定要是MySQL5InnoDBDialect
注意是MySQL5InnoDBDialect不是MySQLInnoDBDialect,
如何用MySQLInnoDBDialect再使用
 ApplicationContext act = new ClassPathXmlApplicationContext("beans.xml");
      SessionFactory sf =(SessionFactory) act.getBean("mySessionFactory");无法创建表!
如果之前写的不是MySQL5InnoDBDialect,改完beans.xml中的<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>后
需要删除之前创建的表,然后重新创建
 ApplicationContext act = new ClassPathXmlApplicationContext("beans.xml");
      SessionFactory sf =(SessionFactory) act.getBean("mySessionFactory");
如果不删除相关表重新创建还是会出现最开始的错误错误!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值