小编Paw*_*iak的帖子

PlayFramework 2 + Ebean - 原始Sql Update查询 - 对db没有影响

我有一个想要修改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)

postgresql transactions sql-update ebean playframework-2.0

7
推荐指数
2
解决办法
2769
查看次数