开发者

specify query timeout when using toplink essential query hint

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 ti开发者_如何学JAVAmeout 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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜