OpenJPA脏读提示
我们有以下 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.我现在遇到了非常相似的问题 - 似乎设置:
可以解决问题。不幸的是,源代码显示来自
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:
would do the trick. Unfortunately, the source code reveals that the constant
withURClause
fromorg.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.