今天做项目的过程中用级联添加数据时报异常如下:
仔细检查配置文件原来是在student.hbm.xml中将Id设置成了自动生成,而在页面又再次赋值,因此发出了upload语句,因此此时的事务还没提交,异常数据库中的行数为0,而修改时却要求有1条记录,故报此错。
WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: insert into test.dbo.Team (tname, tid) values (?, ?)
org.hibernate.StaleStateException:
Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Hibernate: update Student set sname=?, age=?, cardId=?, tid=? where sid=?