2007-12-28
关于: org.hibernate.StaleStateException: Batch update
关键字: hibernate
在使用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操作!!
from: http://www.blogjava.net/mose2006/archive/2007/09/28/149034.html
用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操作!!
from: http://www.blogjava.net/mose2006/archive/2007/09/28/149034.html
发表评论
- 浏览: 84762 次

- 详细资料
搜索本博客
我的相册
jlsave
共 9 张
共 9 张
最近加入圈子
最新评论
-
关于在tomcat下配置 error ...
您好 這裡有引用您的文章 http://herolin.mine.nu/entr ...
-- by herolin -
如果根据递归表高效的生成 ...
可以在id上下功夫 10--->root 1 1001-->子类1 1002 ...
-- by ray_linn -
如果根据递归表高效的生成 ...
是啊一般都会用map
-- by rinapt -
如果根据递归表高效的生成 ...
这种问题我比较喜欢用map,首先map本身就是个树型结构,可以用他的实现类tre ...
-- by baallee -
如果根据递归表高效的生成 ...
第二步 好像一次遍历也完不成吧。
-- by icess






评论排行榜