我有一个想要修改db中的行的play framework 2.0.4应用程序.
我需要将db中的'less'消息更新为"打开"状态(读取消息)我就像下面这样做了
String sql = " UPDATE message SET opened = true, opened_date = now() "
+" WHERE id_profile_to = :id1 AND id_profile_from = :id2 AND opened IS NOT true";
SqlUpdate update = Ebean.createSqlUpdate(sql);
update.setParameter("id1", myProfileId);
update.setParameter("id2", conversationProfileId);
int modifiedCount = update.execute();
Run Code Online (Sandbox Code Playgroud)
我修改了postgresql来记录所有查询.
modifiedCount是修改行的实际数量 - 但查询是在事务中.在db中完成查询之后会有ROLLBACK - 因此不会进行UPDATE.我试图将db更改为H2 - 结果相同.
这是来自postgres审核日志的查询
2012-12-18 00:21:17 CET : S_1: BEGIN
2012-12-18 00:21:17 CET : <unnamed>: UPDATE message SET opened = true, opened_date = now() WHERE id_profile_to = $1 AND id_profile_from = …Run Code Online (Sandbox Code Playgroud)