使用 toplink 基本查询提示时指定查询超时

发布于 2024-08-25 14:43:42 字数 470 浏览 3 评论 0原文

对于 glassfish v2,我在网上进行了搜索,但无论如何都找不到在使用 TopLink 基本查询提示时指定查询超时的信息。我们还有另一个选择迁移到 EclipseLink,但这并不可行。

已经尝试过解决方案 http://forums.oracle.com/forums/thread .jspa?threadID=974732&tstart=-1 但似乎可以设置超时值的DatabaseQuery实际上是Toplink的,而不是TopLink必需的。

除了查询提示之外,我们是否还有其他方法来指示 JDBC 驱动程序设置此超时值?我需要在查询的基础上而不是在系统的基础上执行此操作(这只是更改 DISTRIBUTED_LOCK_TIMEOUT 的值)

For glassfish v2, I have searched through the web and I cannot find anyway to specify query timeout when using TopLink essential query hint. We have another option to migrate to EclipseLink but that is not feasible.

have tried the solution in
http://forums.oracle.com/forums/thread.jspa?threadID=974732&tstart=-1
but it seems the DatabaseQuery which one could set a timeout value is actually for Toplink, not TopLink essential.

Do we have some other way to instruct the JDBC driver for this timeout value other than the query hint? I need to do it on query-basis and not system-basis (which is just to change the value of DISTRIBUTED_LOCK_TIMEOUT)

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

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

发布评论

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

评论(1

清君侧 2024-09-01 14:43:42

根据 Toplink JPA 关于 的文档查询提示

您可以使用以下 TopLink JPA
提示(有关这些的更多详细信息
设置请参考TopLink
文档)

  • fetchSize 接受一个整数。允许
    用户设置 a 的 fetchSize
    TopLink查询。
  • referenceClass 采取
    一堂课。覆盖目标类
    查询。
  • cacheUsage 需要
    整数。描述 TopLink 如何制作
    使用缓存来查询对象。
  • 刷新 采用布尔值。如果应该刷新缓存,则设置为 true
    数据库。
  • lockMode 采用
    整数。设置为悲观锁定。
  • 表达式 采用 TopLink Expression 对象。用于查询
    使用 TopLink API。
  • 超时
    整数。设置查询超时时间
    毫秒。

所以我的理解是你应该能够做到这一点:

Query queryEmployeesByFirstName = em.createNamedQuery("findAllEmployeesByFirstName");
queryEmployeesByFirstName.setHint("timeout", new Integer(5000));

虽然没有经过测试。

According to the documentation of Toplink JPA about Query Hints:

You can use the following TopLink JPA
hints (for more details on these
settings please refer to the TopLink
documentation)

  • fetchSize Takes an Integer. Allows
    the user to set the fetchSize of a
    TopLink query.
  • referenceClass Takes
    a class. Override the target class of
    the query.
  • cacheUsage Takes an
    Integer. Describes how TopLink makes
    use of the cache for querying objects.
  • refresh Takes a Boolean. Set to true if the cache should be refreshed from
    the database.
  • lockMode Takes an
    Integer. Set for Pessimistic Locking.
  • expression Takes a TopLink Expression object. Used for querying
    using TopLink API.
  • timeout Takes an
    Integer. Sets the the query timeout in
    milseconds.

So my understanding is that you should be able to do that:

Query queryEmployeesByFirstName = em.createNamedQuery("findAllEmployeesByFirstName");
queryEmployeesByFirstName.setHint("timeout", new Integer(5000));

Not tested though.

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