zhainanchunchun 2014年01月25日
关于Hibernate 双向一对多的 级联 删除和增加问题
Rpt_dy_report(one)和 Rpt_dy_outputcol (many) 两个实体类 是一对多的双向关系
增加记录的时候 save(Rpt_dy_report) 能够成功的同时增加a和b 的记录
删除记录的时候 delete(Rpt_dy_report) 也能够成功的同时删掉a和b的记录

现在问题是 当执行完删除操作 在执行增加记录的时候 save(Rpt_dy_report)报错!!!
现在给出报错代码

ps: 不太明白为什么insert语句执行完后还要执行 update语句

Hibernate: select rpt_dy_rep0_.report_id as report1_9_, rpt_dy_rep0_.createTime as createTi2_9_, rpt_dy_rep0_.createUserName as createUs3_9_, rpt_dy_rep0_.operTime as operTime4_9_, rpt_dy_rep0_.operUserName as operUser5_9_, rpt_dy_rep0_.hotel_id as hotel10_9_, rpt_dy_rep0_.query_type as query6_9_, rpt_dy_rep0_.querysql as querysql7_9_, rpt_dy_rep0_.report_name as report8_9_, rpt_dy_rep0_.report_title as report9_9_ from Rpt_dy_report rpt_dy_rep0_ where 1=1 and rpt_dy_rep0_.report_name=?
Hibernate: insert into Rpt_dy_report (createTime, createUserName, operTime, operUserName, hotel_id, query_type, querysql, report_name, report_title) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Rpt_dy_outputcol (createTime, createUserName, operTime, operUserName, col_attributename, col_datatype, col_realname, display_status, display_width, isGroup, isOrder, isquery, isstatistics, orderType, output_order, query_con, report_id, statistics_group, statistics_type) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Rpt_dy_outputcol (createTime, createUserName, operTime, operUserName, col_attributename, col_datatype, col_realname, display_status, display_width, isGroup, isOrder, isquery, isstatistics, orderType, output_order, query_con, report_id, statistics_group, statistics_type) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Rpt_dy_outputcol (createTime, createUserName, operTime, operUserName, col_attributename, col_datatype, col_realname, display_status, display_width, isGroup, isOrder, isquery, isstatistics, orderType, output_order, query_con, report_id, statistics_group, statistics_type) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into Rpt_dy_outputcol (createTime, createUserName, operTime, operUserName, col_attributename, col_datatype, col_realname, display_status, display_width, isGroup, isOrder, isquery, isstatistics, orderType, output_order, query_con, report_id, statistics_group, statistics_type) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update Rpt_dy_outputcol set createTime=?, createUserName=?, operTime=?, operUserName=?, col_attributename=?, col_datatype=?, col_realname=?, display_status=?, display_width=?, isGroup=?, isOrder=?, isquery=?, isstatistics=?, orderType=?, output_order=?, query_con=?, report_id=?, statistics_group=?, statistics_type=? where outputcol_id=?
Hibernate: update Rpt_dy_report set createTime=?, createUserName=?, operTime=?, operUserName=?, hotel_id=?, query_type=?, querysql=?, report_name=?, report_title=? where report_id=?
Hibernate: update Rpt_dy_outputcol set createTime=?, createUserName=?, operTime=?, operUserName=?, col_attributename=?, col_datatype=?, col_realname=?, display_status=?, display_width=?, isGroup=?, isOrder=?, isquery=?, isstatistics=?, orderType=?, output_order=?, query_con=?, report_id=?, statistics_group=?, statistics_type=? where outputcol_id=?
Hibernate: update Rpt_dy_outputcol set createTime=?, createUserName=?, operTime=?, operUserName=?, col_attributename=?, col_datatype=?, col_realname=?, display_status=?, display_width=?, isGroup=?, isOrder=?, isquery=?, isstatistics=?, orderType=?, output_order=?, query_con=?, report_id=?, statistics_group=?, statistics_type=? where outputcol_id=?
Hibernate: update Rpt_dy_outputcol set createTime=?, createUserName=?, operTime=?, operUserName=?, col_attributename=?, col_datatype=?, col_realname=?, display_status=?, display_width=?, isGroup=?, isOrder=?, isquery=?, isstatistics=?, orderType=?, output_order=?, query_con=?, report_id=?, statistics_group=?, statistics_type=? where outputcol_id=?
Hibernate: update Rpt_dy_outputcol set createTime=?, createUserName=?, operTime=?, operUserName=?, col_attributename=?, col_datatype=?, col_realname=?, display_status=?, display_width=?, isGroup=?, isOrder=?, isquery=?, isstatistics=?, orderType=?, output_order=?, query_con=?, report_id=?, statistics_group=?, statistics_type=? where outputcol_id=?
org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:181)
at org.springframework.orm.hibernate4.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:680)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:562)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at com.hanb.hotel.service.report.ReportServiceImpl$$EnhancerByCGLIB$$d125196b.addDy_report(<generated>)
at com.hanb.hotel.action.report.ReportAction.addDy_report(ReportAction.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke
...全文
186 点赞 收藏 1
写回复
1 条回复

还没有回复,快来抢沙发~

发动态
发帖子
Web 开发
创建于2007-09-28

5.2w+

社区成员

34.1w+

社区内容

Java Web 开发
社区公告
暂无公告