当前位置: 首页 > 知识库问答 >
问题:

hibernate异常:批量更新从更新[0]返回意外的行数;实际行数:0;预期:1

谢烨烨
2023-03-14

当我试图保存预订到DB,我得到了StaleStateExc0019。在我的情况下,我有一个预订实体,预订号是主键,而不是自动增量。所以我的逻辑是:

>

  • 生成预订号并将其设置为预订。

    调用会话。save()

    顺便说一下,我正在使用hibernate3 spring MySql5。5并在tomcat6中运行,有关更多详细信息,请参阅我的编码和日志:

    预订实体

    @Entity
    @Table(name="booking")
    public class Booking extends BaseModel{
    
        public Booking(){
        }
        @Id
        @Column(length=50)
        private String bookingNo;
        @Column(length=50,nullable=false)
        private String bookedBy;
        @Column(length=1,nullable=false)
        private String status;
        @Column(nullable=false)
        private Date createDate;
        @Column(nullable=false)
        private Date bookingDate;
    

    预订DAO保存功能

    @Override
        @Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
        public Object save(Object object) {
            logger.debug("save() start,save booking["+object+"] to DB");
            Booking booking = (Booking)object;
            String bookingNo;
            //Step 1:Check if booking no is empty,if empty,generate booking no by customer first
            if(booking.getBookingNo() == null || booking.getBookingNo().trim().isEmpty()){
                logger.debug("save(),find booking no is empty,will generate booking no first");
                    bookingNo = (String) generateBookingNo(booking.getCustomer());
                    //Set generated booking no to booking
                    booking.setBookingNo(bookingNo);
            }
            //Step 2:Get hibernate session
            Session session = sf.getCurrentSession();
            logger.debug("save(),get session and start save booking");
            //Step 3:Save booking
             session.save(booking);
            logger.debug("After save booking,the booking is ["+booking+"]");
            return booking;
    
    }
    

    当我的struts2操作调用save函数来保存预订时,它将得到以下错误

    13:23:32,703 ERROR AbstractBatcher:51 - Exception executing batch: 
    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
        at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
        at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
        at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
        at com.chailie.booking.dao.impl.booking.BookingDAO$$EnhancerByCGLIB$$abf7a248.save(<generated>)
        at com.chailie.booking.control.BookingAction.save(BookingAction.java:100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
        at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
        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:248)
        at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
        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:248)
        at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at com.chailie.booking.interceptor.InitToDoItemInterceptor.doIntercept(InitToDoItemInterceptor.java:51)
        at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
        at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
        at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
        at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
        at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:722)
    

    似乎发生这个错误时,代理试图提交事务在保存功能结束,但我不知道是什么导致了这个问题,有人能告诉我为什么我会有这个问题吗?ps:如果你需要更多的编码或日志,请告诉我,我会根据你的要求发布

    调试级别中的更多Hibernate日志

    22:46:55,768 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    22:46:55,768 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    22:46:55,769 DEBUG SQL:393 - insert into dpac_todoitem (assignedBy, assignedDate, assignedTo, bookingNo, cancelledBy, cancelledDate, completedBy, completedDate, createDate, serviceCode, serviceDesc, status, timestamp, actDeliveredPkg, actDeliveredTime, actDispatchedTime, estDeliveredTime, sequence) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    22:46:55,769 DEBUG SQL:393 - insert into dpac_todoitem (assignedBy, assignedDate, assignedTo, bookingNo, cancelledBy, cancelledDate, completedBy, completedDate, createDate, serviceCode, serviceDesc, status, timestamp, actDeliveredPkg, actDeliveredTime, actDispatchedTime, estDeliveredTime, sequence) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    22:46:55,770 DEBUG AbstractBatcher:476 - preparing statement
    22:46:55,770 DEBUG AbstractBatcher:476 - preparing statement
    22:46:55,771 DEBUG AbstractEntityPersister:1942 - Dehydrating entity: [com.chailie.booking.model.todo.DPAC#425988]
    22:46:55,771 DEBUG AbstractEntityPersister:1942 - Dehydrating entity: [com.chailie.booking.model.todo.DPAC#425988]
    22:46:55,772 DEBUG StringType:80 - binding 'chailieyang' to parameter: 1
    22:46:55,772 DEBUG StringType:80 - binding 'chailieyang' to parameter: 1
    22:46:55,773 DEBUG TimestampType:80 - binding '2013-04-29 00:00:00' to parameter: 2
    22:46:55,773 DEBUG TimestampType:80 - binding '2013-04-29 00:00:00' to parameter: 2
    22:46:55,774 DEBUG StringType:80 - binding 'chailieyang' to parameter: 3
    22:46:55,774 DEBUG StringType:80 - binding 'chailieyang' to parameter: 3
    22:46:55,775 DEBUG StringType:73 - binding null to parameter: 4
    22:46:55,775 DEBUG StringType:73 - binding null to parameter: 4
    22:46:55,775 DEBUG StringType:80 - binding '' to parameter: 5
    22:46:55,775 DEBUG StringType:80 - binding '' to parameter: 5
    22:46:55,778 DEBUG TimestampType:73 - binding null to parameter: 6
    22:46:55,778 DEBUG TimestampType:73 - binding null to parameter: 6
    22:46:55,778 DEBUG StringType:80 - binding '' to parameter: 7
    22:46:55,778 DEBUG StringType:80 - binding '' to parameter: 7
    22:46:55,779 DEBUG TimestampType:73 - binding null to parameter: 8
    22:46:55,779 DEBUG TimestampType:73 - binding null to parameter: 8
    22:46:55,780 DEBUG TimestampType:73 - binding null to parameter: 9
    22:46:55,780 DEBUG TimestampType:73 - binding null to parameter: 9
    22:46:55,780 DEBUG StringType:80 - binding 'DPAC' to parameter: 10
    22:46:55,780 DEBUG StringType:80 - binding 'DPAC' to parameter: 10
    22:46:55,781 DEBUG StringType:80 - binding 'DPAC' to parameter: 11
    22:46:55,781 DEBUG StringType:80 - binding 'DPAC' to parameter: 11
    22:46:55,781 DEBUG StringType:80 - binding 'PENDING' to parameter: 12
    22:46:55,781 DEBUG StringType:80 - binding 'PENDING' to parameter: 12
    22:46:55,782 DEBUG TimestampType:80 - binding '2013-04-29 22:46:55' to parameter: 13
    22:46:55,782 DEBUG TimestampType:80 - binding '2013-04-29 22:46:55' to parameter: 13
    22:46:55,783 DEBUG IntegerType:73 - binding null to parameter: 14
    22:46:55,783 DEBUG IntegerType:73 - binding null to parameter: 14
    22:46:55,784 DEBUG TimestampType:73 - binding null to parameter: 15
    22:46:55,784 DEBUG TimestampType:73 - binding null to parameter: 15
    22:46:55,784 DEBUG TimestampType:73 - binding null to parameter: 16
    22:46:55,784 DEBUG TimestampType:73 - binding null to parameter: 16
    22:46:55,785 DEBUG TimestampType:73 - binding null to parameter: 17
    22:46:55,785 DEBUG TimestampType:73 - binding null to parameter: 17
    22:46:55,785 DEBUG IntegerType:80 - binding '425988' to parameter: 18
    22:46:55,785 DEBUG IntegerType:80 - binding '425988' to parameter: 18
    22:46:55,786 DEBUG AbstractBatcher:44 - Executing batch size: 1
    22:46:55,786 DEBUG AbstractBatcher:44 - Executing batch size: 1
    22:46:55,787 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    22:46:55,787 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    22:46:55,788 DEBUG AbstractBatcher:525 - closing statement
    22:46:55,788 DEBUG AbstractBatcher:525 - closing statement
    22:46:55,789 DEBUG AbstractCollectionPersister:1090 - Inserting collection: [com.chailie.booking.model.booking.Booking.parts#SAMSUNG-100003]
    22:46:55,789 DEBUG AbstractCollectionPersister:1090 - Inserting collection: [com.chailie.booking.model.booking.Booking.parts#SAMSUNG-100003]
    22:46:55,790 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    22:46:55,790 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    22:46:55,791 DEBUG SQL:393 - update part set bookingNo=? where sequence=?
    22:46:55,791 DEBUG SQL:393 - update part set bookingNo=? where sequence=?
    22:46:55,791 DEBUG AbstractBatcher:476 - preparing statement
    22:46:55,791 DEBUG AbstractBatcher:476 - preparing statement
    22:46:55,793 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,793 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,794 DEBUG IntegerType:80 - binding '8' to parameter: 2
    22:46:55,794 DEBUG IntegerType:80 - binding '8' to parameter: 2
    22:46:55,794 DEBUG AbstractCollectionPersister:1172 - done inserting collection: 1 rows inserted
    22:46:55,794 DEBUG AbstractCollectionPersister:1172 - done inserting collection: 1 rows inserted
    22:46:55,795 DEBUG AbstractCollectionPersister:1090 - Inserting collection: [com.chailie.booking.model.booking.Booking.toDoItems#SAMSUNG-100003]
    22:46:55,795 DEBUG AbstractCollectionPersister:1090 - Inserting collection: [com.chailie.booking.model.booking.Booking.toDoItems#SAMSUNG-100003]
    22:46:55,796 DEBUG AbstractBatcher:44 - Executing batch size: 1
    22:46:55,796 DEBUG AbstractBatcher:44 - Executing batch size: 1
    22:46:55,797 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    22:46:55,797 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    22:46:55,798 DEBUG AbstractBatcher:525 - closing statement
    22:46:55,798 DEBUG AbstractBatcher:525 - closing statement
    22:46:55,799 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    22:46:55,799 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    22:46:55,800 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,800 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,800 DEBUG AbstractBatcher:476 - preparing statement
    22:46:55,800 DEBUG AbstractBatcher:476 - preparing statement
    22:46:55,801 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,801 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,802 DEBUG IntegerType:80 - binding '425984' to parameter: 2
    22:46:55,802 DEBUG IntegerType:80 - binding '425984' to parameter: 2
    22:46:55,803 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,803 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,803 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,803 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,804 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,804 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,805 DEBUG IntegerType:80 - binding '425985' to parameter: 2
    22:46:55,805 DEBUG IntegerType:80 - binding '425985' to parameter: 2
    22:46:55,805 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,805 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,806 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,806 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,807 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,807 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,807 DEBUG IntegerType:80 - binding '425986' to parameter: 2
    22:46:55,807 DEBUG IntegerType:80 - binding '425986' to parameter: 2
    22:46:55,808 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,808 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,808 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,808 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,809 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,809 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,810 DEBUG IntegerType:80 - binding '425987' to parameter: 2
    22:46:55,810 DEBUG IntegerType:80 - binding '425987' to parameter: 2
    22:46:55,810 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,810 DEBUG AbstractBatcher:222 - reusing prepared statement
    22:46:55,811 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,811 DEBUG SQL:393 - update todoitem set bookingNo=? where sequence=?
    22:46:55,812 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,812 DEBUG StringType:80 - binding 'SAMSUNG-100003' to parameter: 1
    22:46:55,812 DEBUG IntegerType:80 - binding '425988' to parameter: 2
    22:46:55,812 DEBUG IntegerType:80 - binding '425988' to parameter: 2
    22:46:55,813 DEBUG AbstractCollectionPersister:1172 - done inserting collection: 5 rows inserted
    22:46:55,813 DEBUG AbstractCollectionPersister:1172 - done inserting collection: 5 rows inserted
    22:46:55,814 DEBUG AbstractBatcher:44 - Executing batch size: 5
    22:46:55,814 DEBUG AbstractBatcher:44 - Executing batch size: 5
    22:46:55,817 ERROR AbstractBatcher:51 - Exception executing batch: 
    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
    
  • 共有1个答案

    夏侯腾
    2023-03-14

    当将todoproject继承策略更改为JOINED时,问题就消失了

    @Entity
    @Table(name="todoitem")
    @Inheritance(strategy=InheritanceType.JOINED)
    public class ToDoItem extends BaseModel{
    
     类似资料:
    • 我和冬眠有麻烦了。 我有个例外 我试图显示数据库中的日期,我的一列是char,在我的类中有一个 ' 我创建了一个来进行转换 `公共类FilialStatusType扩展了TypeHibernate{public static final String TYPE=“FilialStatusType”; ### 有人能帮我吗?

    • 问题内容: 我收到以下hibernate错误。我能够确定导致问题的功能。不幸的是,函数中有多个数据库调用。由于hibernate在事务结束时刷新会话,因此我找不到导致问题的行。下面提到的hibernate错误看起来像是一般错误。甚至都没有提到哪个Bean导致了问题。有人熟悉这个hibernate错误吗? 问题答案: 没有交易的代码和映射,几乎不可能调查问题。 但是,要更好地了解导致问题的原因,请尝

    • 当现有用户发出请求时,该方法首先删除最旧的记录,然后再保存新请求。如果请求传入的速度不太快(使用Oracle数据库),下面的代码可以正常工作。 输出: 但是,如果用户以非常快速的方式提交请求,即happy clicker,则相同的代码会生成StaleStateException错误。 似乎在下一条记录出现之前,代码还没有时间完成更改,导致代码尝试删除同一条记录两次。除了在这种方法之前改变前端或其他

    • 我不明白为什么我会犯这样的错误,我的头撞在墙上已经好几个小时了。 当试图删除数据库中我没有使用Hibernate添加的任何行(即通过常规SQL输入的数据库的所有现有行)时,上面的代码给了我一个错误。 如果我在应用程序中使用Hibernate插入一行,那么就可以完全删除该行。 我不能理解的是,我先从数据库中获取一个用户,这样我就知道这个用户存在。 我已经检查了Hibernate SQL,在运行sel

    • 当我试图从spring mvc应用程序更新数据库中的值时,我遇到了以下错误: 所以我的实际错误似乎是数据库中的ID和正在更新的内容。在我的GET方法中,我得到的是当前ID,在本例中是10。 但在我的post方法中,这个ID是10,突然变成了0,我相信这可能是这个错误的原因? 那么,这可能是什么原因,还是错误是别的什么? JPA课程:

    • 问题内容: 我在下面编写了此方法,该方法假定是从数据库中删除成员记录。但是,当我在servlet中使用它时,它将返回错误。 会员班 控制器部分 HTTP状态500 有时,当我尝试多次执行页面时,甚至会引发此错误。 有人知道究竟是什么引起这些错误吗? 问题答案: 该错误可能是由多种原因引起的。我不为此而功劳,在这里找到了它。 在提交对象之前刷新数据可能会导致清除所有等待持久化的对象。 如果对象具有自