Index: src/java/javax/jdo/Query.java =================================================================== --- src/java/javax/jdo/Query.java (revision 889854) +++ src/java/javax/jdo/Query.java (working copy) @@ -698,22 +698,68 @@ String candidateCollectionExpression, Map parameters); /** - * Specify a timeout interval (milliseconds) for any query executions. - * If a query hasn't completed within this interval execute() will throw a - * JDOQueryTimeoutException. + * Specify a timeout interval (milliseconds) for any read operations + * associated with this query. To unset the explicit timeout for this + * query, specify null. For no timeout, specify 0. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a read operation hasn't completed within this interval, executeXXX + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the query, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. * @since 2.3 - * @param interval The timeout interval (millisecs) + * @param interval the timeout interval (milliseconds) */ - void setTimeoutMillis(Integer interval); + void setDatastoreReadTimeoutMillis(Integer interval); - /** Get the timeout setting for query executions. - * - * @return the query timeout setting. + /** Get the effective timeout setting for read operations. + * If the timeout has not been set on this query explicitly, the effective + * datastore read timeout value from the persistence manager is returned. + * @see #setDatastoreReadTimeoutMillis(Integer) + * @see PersistenceManager#setDatastoreReadTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). * @since 2.3 */ - Integer getTimeoutMillis(); + Integer getDatastoreReadTimeoutMillis(); /** + * Specify a timeout interval (milliseconds) for any write operations + * associated with this query. To unset the explicit timeout for this + * query, specify null. For no timeout, specify 0. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a write operation hasn't completed within this interval, deleteXXX + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the query, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 2.3 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreWriteTimeoutMillis(Integer interval); + + /** Get the effective timeout setting for write operations. + * If the timeout has not been set on this query explicitly, the effective + * datastore write timeout value from the persistence manager is returned. + * @see #setDatastoreWriteTimeoutMillis(Integer) + * @see PersistenceManager#setDatastoreWriteTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + * @since 2.3 + */ + Integer getDatastoreWriteTimeoutMillis(); + + /** * Method to cancel any executing queries. * If the underlying datastore doesn't support cancellation of queries this will * throw JDOUnsupportedOptionException. Index: src/java/javax/jdo/Constants.java =================================================================== --- src/java/javax/jdo/Constants.java (revision 889854) +++ src/java/javax/jdo/Constants.java (working copy) @@ -475,6 +475,14 @@ static String OPTION_QUERY_SQL = "javax.jdo.query.SQL"; /** + * "javax.jdo.option.DatastoreTimeout" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.3 + */ + static String OPTION_DATASTORE_TIMEOUT + = "javax.jdo.option.DatastoreTimeout"; + /** * "javax.jdo.option.UnconstrainedQueryVariables" * * @see PersistenceManagerFactory#supportedOptions() Index: src/java/javax/jdo/PersistenceManagerFactory.java =================================================================== --- src/java/javax/jdo/PersistenceManagerFactory.java (revision 889854) +++ src/java/javax/jdo/PersistenceManagerFactory.java (working copy) @@ -520,22 +520,50 @@ */ void setTransactionIsolationLevel(String level); - /** Set the default query timeout setting for all PersistenceManager - * instances obtained from this factory. - * - * @param interval The default timeout setting (millisecs). + /** + * Specify a default timeout interval (milliseconds) for any read + * operations for persistence managers obtained from this persistence + * manager factory. To unset the explicit timeout, specify null. + * For no timeout, specify 0. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. * @since 2.3 + * @param interval the timeout interval (milliseconds) */ - void setQueryTimeoutMillis(Integer interval); + void setDatastoreReadTimeoutMillis(Integer interval); - /** Get the default query timeout setting for all - * PersistenceManager instances obtained from this factory. - * - * @return the default query timeout setting. + /** Get the default timeout setting for read operations. + * If timeouts are not supported,this method will return null. + * @see #setDatastoreReadTimeoutMillis(Integer) + * @return the default timeout setting (milliseconds). * @since 2.3 */ - Integer getQueryTimeoutMillis(); + Integer getDatastoreReadTimeoutMillis(); + /** + * Specify a default timeout interval (milliseconds) for any write + * operations for persistence managers obtained from this persistence + * manager factory. To unset the explicit timeout, specify null. + * For no timeout, specify 0. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 2.3 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreWriteTimeoutMillis(Integer interval); + + /** Get the default timeout setting for write operations. + * If timeouts are not supported,this method will return null. + * @see #setDatastoreWriteTimeoutMillis(Integer) + * @return the default timeout setting (milliseconds). + * @since 2.3 + */ + Integer getDatastoreWriteTimeoutMillis(); + /** Return non-configurable properties of this * PersistenceManagerFactory. * Properties with keys VendorName and @@ -580,6 +608,7 @@ *
javax.jdo.option.TransactionIsolationLevel.snapshot *
javax.jdo.option.TransactionIsolationLevel.serializable *
javax.jdo.option.QueryCancel + *
javax.jdo.option.DatastoreTimeout *
javax.jdo.query.SQL *
javax.jdo.query.JDOQL * Index: src/java/javax/jdo/PersistenceManager.java =================================================================== --- src/java/javax/jdo/PersistenceManager.java (revision 889854) +++ src/java/javax/jdo/PersistenceManager.java (working copy) @@ -953,22 +953,75 @@ */ boolean getIgnoreCache(); - /** Set the default query timeout setting for all Query - * instances obtained from this PersistenceManager. - * - * @param interval The default timeout setting (millisecs). - * @since 2.3 - */ - void setQueryTimeoutMillis(Integer interval); + /** + * Specify a timeout interval (milliseconds) for any datastore read + * operations associated with this persistence manager. To unset + * the explicit timeout, specify null. For no timeout, specify 0. + * Read operations include, for example, those associated with query, + * getObjectById, refresh, retrieve, and extent iteration operations. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a read operation hasn't completed within this interval, the operation + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the query, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 2.3 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreReadTimeoutMillis(Integer interval); - /** Get the default query timeout setting for all - * Query instances obtained from this PersistenceManager. - * - * @return the default query timeout setting. - * @since 2.3 - */ - Integer getQueryTimeoutMillis(); + /** Get the effective timeout setting for datastore read operations + * associated with this persistence manager. + * If the timeout has not been set on this persistence manager explicitly, + * the default read timeout value from the persistence manager factory + * is returned. + * @see #setDatastoreReadTimeoutMillis(Integer) + * @see PersistenceManagerFactory#setDatastoreReadTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + * @since 2.3 + */ + Integer getDatastoreReadTimeoutMillis(); + /** + * Specify a timeout interval (milliseconds) for any write operations + * associated with this persistence manager. To unset the explicit timeout, + * specify null. For no timeout, specify 0. + * Datastore write operations include, for example, operations associated + * with flush, commit, and delete by query. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a write operation hasn't completed within this interval, methods + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the method, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 2.3 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreWriteTimeoutMillis(Integer interval); + + /** Get the effective timeout setting for write operations. + * If the timeout has not been set on this persistence manager explicitly, + * the default datastore write timeout value from the persistence manager + * factory is returned. + * @see #setDatastoreWriteTimeoutMillis(Integer) + * @see PersistenceManagerFactory#setDatastoreWriteTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + * @since 2.3 + */ + Integer getDatastoreWriteTimeoutMillis(); + /** Gets the detachAllOnCommit setting. * @see #setDetachAllOnCommit(boolean) * @since 2.0 Index: src/java/javax/jdo/JDOQueryTimeoutException.java =================================================================== --- src/java/javax/jdo/JDOQueryTimeoutException.java (revision 889854) +++ src/java/javax/jdo/JDOQueryTimeoutException.java (working copy) @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * JDOUnsupportedOptionException.java - * - */ -package javax.jdo; - -/** - * This class represents exceptions caused when a query reaches a specified timeout - * without completing. - * @since 2.3 - */ -public class JDOQueryTimeoutException extends JDOUserException { - /** - * Constructs a new JDOQueryTimeoutException without a detail message. - */ - public JDOQueryTimeoutException() { - } - - /** - * Constructs a new JDOQueryTimeoutException with the specified detail message. - * @param msg the detail message. - */ - public JDOQueryTimeoutException(String msg) { - super(msg); - } -}