OpenJPA脏读提示

发布于 2024-11-10 13:26:52 字数 544 浏览 2 评论 0原文

我们有以下 DAO 堆栈:

  • DB2 9.7 Express-C
  • OpenJPA 2.0.1
  • Spring 3.0.5
  • Bitronix 2.1.1

如何指定 OpenJPA 将 WITH UR sql 子句添加到查询末尾?

我已经浏览了好几天的网站和手册,它应该是这样的:

Query q = em.createQuery("select m from Magazine m where ... ");
q.setHint("openjpa.FetchPlan.ReadLockMode","WRITE");
List r = q.getResultList();

但是,唉,我一直无法找到一个可以作为 setHint() 参数和产量传递的工作 OpenJPA 属性WITH UR 结果,所以我使用 SpringJDBC 查询,不幸的是我不能再使用了。

有什么想法吗?非常感谢

We've got the following DAO stack:

  • DB2 9.7 Express-C
  • OpenJPA 2.0.1
  • Spring 3.0.5
  • Bitronix 2.1.1

How do you specify OpenJPA to add WITH UR sql clause to the end of the query?

I'd browsed sites and manuals alike for days, it should be something like this:

Query q = em.createQuery("select m from Magazine m where ... ");
q.setHint("openjpa.FetchPlan.ReadLockMode","WRITE");
List r = q.getResultList();

but alas, I've been unable to find a working OpenJPA property that would be passed as setHint() argument and yield WITH UR as result, so I use SpringJDBC queries which I unfortunately can't use any longer.

Any ideas? Thank you very much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘿咻 2024-11-17 13:26:52

OpenJPA 不支持将 WITH UR 子句与 JPQL 结合使用。您始终可以使用本机查询来实现此功能。

OpenJPA doesn't support using the WITH UR clause with JPQL. You could always use a native query for this functionality.

自由如风 2024-11-17 13:26:52

我现在遇到了非常相似的问题 - 似乎设置:

query.setHint("openjpa.FetchPlan.Isolation", "READ_UNCOMMITTED");

可以解决问题。不幸的是,源代码显示来自 org.apache.openjpa.jdbc.sql.DB2Dictionary 的常量 withURClause 永远不会被读取。

此外,如果查询不是 FOR UPDATE,OpenJPA 从不 会考虑获取计划提示。我有一个 select 语句被独占锁阻塞,它确实可以处理未提交的数据——这对 OpenJPA 来说是不行的。

I'm having quite a similar problem now — it would seem that setting:

query.setHint("openjpa.FetchPlan.Isolation", "READ_UNCOMMITTED");

would do the trick. Unfortunately, the source code reveals that the constant withURClause from org.apache.openjpa.jdbc.sql.DB2Dictionary is never read.

Additionally OpenJPA never takes into account a fetch plan hint if the query is not FOR UPDATE. I have a select statement that gets blocked on exclusive locks and it could really work with uncommitted data — a no-go with OpenJPA.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文