删除播放时乐观锁定!骨架

时间:2013-05-27 15:23:51

标签: java jpa playframework-2.0 ebean

我的应用基于Play! Framework + PostgreSQL。 当我循环访问从数据库中检索到的对象列表时,我无法摆脱这种乐观的锁定异常。

175         List<SocialAction> friendAction = SocialAction.findSocialActionsWithFieldFriendIdAndInterest
176         (interest, user);
177
178         for (SocialAction action : friendAction) {
179             action.delete();
180         }
181         
182         socialInterest.delete();

浏览器中的例外:

Execution exception
[OptimisticLockException: Data has changed. updated [0] rows sql[delete from social_action where id=? and date=? and suggest_comment=? and social_interest_id=? and origin_socialaction_id=? and activity_id=? and friend_id=?] bind[null]]
In /Users/aaaaa/Documents/aaaaa-remote/app/models/SocialInterest.java at line 179.

在终端

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[OptimisticLockException: Data has changed. updated [0] rows sql[delete from social_action where id=? and date is null and suggest_comment is null and social_interest_id is null and origin_socialaction_id is null and activity_id is null and friend_id is null] bind[null]]]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [play_2.9.1.jar:2.0.4]
at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [play_2.9.1.jar:2.0.4]
at akka.actor.Actor$class.apply(Actor.scala:318) [akka-actor.jar:2.0.2]
at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0.4]
at akka.actor.ActorCell.invoke(ActorCell.scala:626) [akka-actor.jar:2.0.2]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) [akka-actor.jar:2.0.2]
Caused by: javax.persistence.OptimisticLockException: Data has changed. updated [0] rows sql[delete from social_action where id=? and date is null and suggest_comment is null and social_interest_id is null and origin_socialaction_id is null and activity_id is null and friend_id is null] bind[null]
at com.avaje.ebeaninternal.server.persist.dml.DmlHandler.checkRowCount(DmlHandler.java:123) ~[ebean.jar:na]
at com.avaje.ebeaninternal.server.persist.dml.DeleteHandler.execute(DeleteHandler.java:81) ~[ebean.jar:na]
at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:105) ~[ebean.jar:na]
at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.delete(DmlBeanPersister.java:67) ~[ebean.jar:na]
at com.avaje.ebeaninternal.server.persist.DefaultPersistExecute.executeDeleteBean(DefaultPersistExecute.java:128) ~[ebean.jar:na]
at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeNow(PersistRequestBean.java:535) ~[ebean.jar:na]

在此代码之前调用的方法中,似乎先前已从DB中删除了该行。 但是当我调用findSocialActions()时,它不应该出现在列表中。所以不会有例外。

你有什么想法吗?

感谢。

0 个答案:

没有答案