Err:Could not execute JDBC batch update


org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
    ......
Caused by: java.sql.BatchUpdateException: Cannot delete or update a parent row: a foreign key constraint fails (`museum/bbs_write`, CONSTRAINT `FKF2B104D3D05BEE4D` FOREIGN KEY (`userid`) REFERENCES `user` (`id`))
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1566)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)

 

 

我这出现这个问题原因是Hibernate关联设置问题 我只在一个帖子配置中使用了many-to-one,在用户配置中没有做任何设置

修改many-to-one中的cascade="none" 

 

update:进行update操作时是否包含此字段
insert:进行insert操作时是否包含此字段
name:映射类属性的名字
column:关联的字段
class:关联类的名字
cascade:设置操作中的级联策略 可选值为 all所有操作情况均进行级联、none所有操作情况均不进行级联、save-update执行save和update操作时级联、delete执行删除操作时级联
fetch:设置抓取数据的策略 默认值为select序列选择抓取 可选值为join外连接抓取

posted @ 2009-12-24 15:33  TQ.CH  阅读(3687)  评论(0编辑  收藏  举报