浏览 2782 次
锁定老帖子 主题:关于grails中锁的问题
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-07
AController(){ def aService def insertSome(){ aService.insert() } } AService(){ def insert(){ for(po in poListFromRequest){ po.save() } for(po2 in po2ListFromRequest){ po2.save() } } } class Po1Job{ //定时的变量设置 def timeout = 10000l //delete 操作 def delFuntion(){ def poList = Po.list() //将 po 表中的数据全部转移到 polog 表中 for(po in poList){ //假设po表中无重复数据 def polog = new PoLog() polog.properties= po.properties polog.save() com.mysite.EmailUtil.send(); //发送email po.delete() } } } //同 Po1Job class Po2Job{ //定时的变量设置 def timeout = 10000l //delete 操作 def delFuntion(){ def po2List = Po2.list() //将po2 表中的数据全部转移到 po2log 表中 for(po2 in po2List){ def po2log = new Po2Log() po2log.properties= po2.properties po2log.save() com.mysite.EmailUtil.send(); //发送email po2.delete(); } } } 结果出现了下面错误 org.quartz.SchedulerException: JobListener 'sessionBinderListener' threw exceptiwas incorrect): [po#14] [See nested exception: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction org.hibernate.StaleObjectStateException: Row was updated or deleted by another t ransaction (or unsaved-value mapping was incorrect): [po#14] at org.hibernate.persister.entity.AbstractEntityPersister.check(Abstract EntityPersister.java:1765) at org.hibernate.persister.entity.AbstractEntityPersister.delete(Abstrac tEntityPersister.java:2523) at org.hibernate.persister.entity.AbstractEntityPersister.delete(Abstrac tEntityPersister.java:2697) at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.ja va:74) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio ns(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus hEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.codehaus.groovy.grails.plugins.quartz.listeners.SessionBinderJobL istener.jobWasExecuted(SessionBinderJobListener.java:55) at org.quartz.core.QuartzScheduler.notifyJobListenersWasExecuted(QuartzS cheduler.java:1659) at org.quartz.core.JobRunShell.notifyJobListenersComplete(JobRunShell.ja va:352) at org.quartz.core.JobRunShell.run(JobRunShell.java:227) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.j ava:520) 哪位达人能解释一下为什么出现乐观锁异常么? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-05-08
我也顶 我开发中也出现了这个问题
|
|
返回顶楼 | |
发表时间:2008-05-08
使用withTransaction方法自己控制事务,看看呢
|
|
返回顶楼 | |