org.hibernate.StaleStateException报错

 
  

HTTP Status 500 -


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.orm.hibernate3.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
	org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:675)
	org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:793)
	org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:664)
	org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
	org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
	org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:412)
	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
	com.qq.service.StudentService$$EnhancerByCGLIB$$56df6193.updateStudent()
	com.qq.action.StudentAction.updateStudent(StudentAction.java:190)

.............................

root cause

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
	org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85)
	org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
	org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:90)
	org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
	org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
	org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
	org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
	org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
	org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
	org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
	org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
	org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
	org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(Hibern.......
 
  
 
  
 
  
错误原因:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
这个异常是由于主键设置为自增长,而在我们插入记录的时候设置了ID的值导致的。看下我的Hibernate映射文件中ID的定义

你可能感兴趣的:(错误)