posts - 44,  comments - 48,  trackbacks - 0
在使用hibernate项目中,持久化类的ID用Long与long有很大区别!!
用long 作为id,当一个新的临时类要持久化时会报一个这种错:
Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
因为这个临时类,已经有一个id=0 (long的默认值);这时hibernate 为错认为这是一条持久化类,从而进行更新操作,故报错!!
这时把持久类的id 类型改成Long 就OK了,再create 时,临时类的id为null ,hibernate 才会正确的判断这是临时类而进行save操作!!
posted on 2007-09-28 11:42 摩西 阅读(2418) 评论(1)  编辑  收藏 所属分类: work_2007

只有注册用户登录后才能发表评论。


网站导航: