本文整理匯總了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);
}
}