日期:2014-05-20  浏览次数:20864 次

大侠们帮忙看看这个是什么问题关于外键约束的Cannot add or update a child row: a foreign key constraint
Struts Problem Report
Struts has detected an unhandled exception: 

Messages: Cannot add or update a child row: a foreign key constraint fails (`myshop`.`t_product`, CONSTRAINT `FKA91FC0248049AD0` FOREIGN KEY (`productCategory_id`) REFERENCES `t_product_category` (`id`)) 
Could not execute JDBC batch update 
Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update 
 
File: com/mysql/jdbc/ServerPreparedStatement.java 
Line number: 648 


--------------------------------------------

Stacktraces
org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update 
  org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:636)
  org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:789)
  org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:663)
  org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)
  org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)
  org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
  org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
  org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
  org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
  org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
  $Proxy17.save(Unknown Source)
  com.zz.service.impl.ProductServiceImpl.save(ProductServiceImpl.java:243)
  com.zz.action.admin.ProductAction.save(ProductAction.java:93)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  java.lang.reflect.Method.invoke(Method.java:597)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
   
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update 
  org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
  org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
  org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
  org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
  org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
  org.hibernate.event.def.AbstractFlushingEventListener.performExecutions  
java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`myshop`.`t_product`, CONSTRAINT `FKA91FC0248049AD0` FOREIGN KEY (`productCategory_id`) REFERENCES `t_product_category` (`id`))