Org.hibernate.StaleStateException:Batch Update returned unexpected row count from Update [0]; Actual row count:0; Expected:1
Cause of Error:
Use Hibernate's Saveorupdate method to save the instance. The Saveorupdate method requires an ID of NULL to execute save and, in other cases, to perform the update. When saving the instance is added, but your ID is not NULL, so the update is used, but there is no primary key related value in the database, so an exception occurs.
In the action, Java code:
Public String updatestudent () {
Student s = new Student ();
try {
Beanutils.copyproperties (S, student); Reduce the amount of code by processing the properties of the JavaBean using the reflection mechanism
} catch (Illegalaccessexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
} catch (InvocationTargetException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
S.setid (ID); Get the ID number of the student you want to update on the page
Studentservice.updatestudent (s);
return Querystudent ();
}
Note: The Beanutils import is org.apache.commons.beanutils.BeanUtils.
Use the links below to view the http://www.cnblogs.com/fayf/archive/2008/08/21/1272982.html
The above represents only personal views, welcome everyone to make bricks (* ^_^ *)
Org.hibernate.StaleStateException occurs when you use the Hibernate update operation