本文整理汇总了Java中javax.jdo.Query.setDatastoreReadTimeoutMillis方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setDatastoreReadTimeoutMillis方法的具体用法?Java Query.setDatastoreReadTimeoutMillis怎么用?Java Query.setDatastoreReadTimeoutMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jdo.Query
的用法示例。
在下文中一共展示了Query.setDatastoreReadTimeoutMillis方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyTransactionTimeout
import javax.jdo.Query; //导入方法依赖的package包/类
/**
* Apply the current transaction timeout, if any, to the given JDO Query object.
* @param query the JDO Query object
* @param pmf JDO PersistenceManagerFactory that the Query was created for
* @throws JDOException if thrown by JDO methods
*/
public static void applyTransactionTimeout(Query query, PersistenceManagerFactory pmf) throws JDOException {
Assert.notNull(query, "No Query object specified");
PersistenceManagerHolder pmHolder =
(PersistenceManagerHolder) TransactionSynchronizationManager.getResource(pmf);
if (pmHolder != null && pmHolder.hasTimeout() &&
pmf.supportedOptions().contains("javax.jdo.option.DatastoreTimeout")) {
int timeout = (int) pmHolder.getTimeToLiveInMillis();
query.setDatastoreReadTimeoutMillis(timeout);
query.setDatastoreWriteTimeoutMillis(timeout);
}
}