【问题标题】:Pessimistic locking is not working with Query API悲观锁定不适用于查询 API
【发布时间】:2010-06-16 13:01:55
【问题描述】:
List esns=session.createQuery("from Pool e where e.status=:status "+
                        "order by uuid asc")
                        .setString("status", "AVAILABLE")
                        .setMaxResults(n)
                        .setLockMode("e", LockMode.PESSIMISTIC_WRITE)
                        .list();

我已经编写了上述查询,但是它没有生成 for update 查询并且正在同时更新。

我使用的是 3.5.2 版本,它有一个 bug in Criteria API,查询 API 中是否也存在相同的错误或者我做错了什么?

【问题讨论】:

    标签: hibernate pessimistic-locking


    【解决方案1】:

    setLockOptions 工作正常。是same bug as this one

    【讨论】:

      【解决方案2】:

      尝试使用LockModeType.PESSIMISTIC_FORCE_INCREMENT,看看this solution

      【讨论】:

        猜你喜欢
        • 2014-11-12
        • 1970-01-01
        • 2010-09-12
        • 1970-01-01
        • 2014-08-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多