openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r755113 - in /openjpa/trunk/openjpa-jdbc/src/main: java/org/apache/openjpa/jdbc/kernel/ java/org/apache/openjpa/jdbc/meta/strats/ java/org/apache/openjpa/jdbc/schema/ java/org/apache/openjpa/jdbc/sql/ resources/org/apache/openjpa/jdbc/sql/
Date Tue, 17 Mar 2009 04:39:58 GMT
Author: jrbauer
Date: Tue Mar 17 04:39:56 2009
New Revision: 755113

URL: http://svn.apache.org/viewvc?rev=755113&view=rev
Log:
OPENJPA-878 Committing code, tests, and documentation updates for Donald Woods.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ClassNameDiscriminatorStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedLobFieldStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLErrorCodeReader.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
Tue Mar 17 04:39:56 2009
@@ -149,7 +149,7 @@
                     dict.setUnknown(stmnt, i+1, params[i], _pkCols[i]);
                 }
             }
-
+            dict.setTimeouts(stmnt, (JDBCFetchConfiguration)fetch, forUpdate);
             rs = _select.executeQuery(conn, stmnt, getQueryString(), jstore,
                 params, _pkCols);
             return _select.getEagerResult(conn, stmnt, rs, jstore, 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
Tue Mar 17 04:39:56 2009
@@ -30,6 +30,7 @@
 import java.util.Map;
 
 import org.apache.openjpa.event.LifecycleEventManager;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.kernel.exps.ExpContext;
 import org.apache.openjpa.jdbc.kernel.exps.GetColumn;
 import org.apache.openjpa.jdbc.kernel.exps.JDBCExpressionFactory;
@@ -512,6 +513,7 @@
                 stmnt = null;
                 try {
                     stmnt = prepareStatement(conn, sql[i]);
+                    dict.setTimeouts(stmnt, fetch, true);
                     count += executeUpdate(conn, stmnt, sql[i], isUpdate);              
     
                 } catch (SQLException se) {
                     throw SQLExceptions.getStore(se, sql[i].getSQL(), 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/NativeJDBCSeq.java
Tue Mar 17 04:39:56 2009
@@ -290,10 +290,12 @@
      */
     private long getSequence(Connection conn)
         throws SQLException {
+        DBDictionary dict = _conf.getDBDictionaryInstance();
         PreparedStatement stmnt = null;
         ResultSet rs = null;
         try {
             stmnt = conn.prepareStatement(_select);
+            dict.setTimeouts(stmnt, _conf, false);
             synchronized(this) {
                 rs = stmnt.executeQuery();
             }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
Tue Mar 17 04:39:56 2009
@@ -111,6 +111,7 @@
         // construct; if not, and we the assertion does not throw an
         // exception, then just return without locking
         DBDictionary dict = _store.getDBDictionary();
+        JDBCFetchConfiguration fetch = _store.getFetchConfiguration();
         if (dict.simulateLocking)
             return;
         dict.assertSupport(dict.supportsSelectForUpdate,
@@ -125,7 +126,7 @@
         Select select = _store.getSQLFactory().newSelect();
         select.select(mapping.getPrimaryKeyColumns());
         select.wherePrimaryKey(id, mapping, _store);
-        SQLBuffer sql = select.toSelect(true, _store.getFetchConfiguration());
+        SQLBuffer sql = select.toSelect(true, fetch);
 
         ensureStoreManagerTransaction();
         Connection conn = _store.getConnection();
@@ -133,7 +134,7 @@
         ResultSet rs = null;
         try {
             stmnt = prepareStatement(conn, sql);
-            setTimeout(stmnt, timeout);
+            dict.setTimeouts(stmnt, fetch, true);
             rs = executeQuery(conn, stmnt, sql);
             checkLock(rs, sm, timeout);
         } catch (SQLException se) {
@@ -177,23 +178,6 @@
     
     /**
      * This method is to provide override for non-JDBC or JDBC-like 
-     * implementation of setting query timeout.
-     */
-    protected void setTimeout(PreparedStatement stmnt, int timeout)
-        throws SQLException {
-        DBDictionary dict = _store.getDBDictionary();
-        if (timeout >= 0 && dict.supportsQueryTimeout) {
-            if (timeout < 1000) {
-                timeout = 1000;
-                if (log.isWarnEnabled())
-                    log.warn(_loc.get("millis-query-timeout"));
-            }
-            stmnt.setQueryTimeout(timeout / 1000);
-        }
-    }
-    
-    /**
-     * This method is to provide override for non-JDBC or JDBC-like 
      * implementation of executing query.
      */
     protected ResultSet executeQuery(Connection conn, PreparedStatement stmnt, 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
Tue Mar 17 04:39:56 2009
@@ -24,6 +24,7 @@
 import java.sql.SQLException;
 import java.util.Map;
 
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.jdbc.sql.Result;
@@ -101,6 +102,8 @@
                 for (int i = 0; i < params.length; i++)
                     dict.setUnknown(stmnt, ++index, params[i], null);
 
+                dict.setTimeouts(stmnt, fetch, false);
+
                 ResultSet rs = stmnt.executeQuery();
                 
                 SelectImpl cachedSelect = pq.getSelect();

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
Tue Mar 17 04:39:56 2009
@@ -34,6 +34,7 @@
 import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.MappingRepository;
 import org.apache.openjpa.jdbc.meta.QueryResultMapping;
@@ -166,6 +167,8 @@
                 if (stmnt != null)
                     buf.setParameters(stmnt);
 
+                dict.setTimeouts(stmnt, fetch, true);
+                
                 int count = executeUpdate(store, conn, stmnt, buf);  
               
                 return Numbers.valueOf(count);
@@ -218,6 +221,7 @@
                     stmnt != null;)
                     dict.setUnknown(stmnt, ++index, i.next(), null);
 
+                dict.setTimeouts(stmnt, fetch, false);
                 ResultSet rs = executeQuery(store, conn, stmnt, buf, paramList);
                 ResultSetResult res = stmnt != null ? 
                     new ResultSetResult(conn, stmnt, rs, store) :

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
Tue Mar 17 04:39:56 2009
@@ -467,6 +467,7 @@
         PreparedStatement stmnt = null;
         try {
             stmnt = prepareStatement(conn, insert);
+            dict.setTimeouts(stmnt, _conf, true);
             executeUpdate(_conf, conn, stmnt, insert, RowImpl.ACTION_INSERT);
         } finally {
             if (stmnt != null)
@@ -508,9 +509,11 @@
                 null, false, dict.supportsSelectForUpdate, 0, Long.MAX_VALUE,
                 false, true);
 
-        PreparedStatement stmnt = prepareStatement(conn, select);
+        PreparedStatement stmnt = null;
         ResultSet rs = null;
         try {
+            stmnt = prepareStatement(conn, select);
+            dict.setTimeouts(stmnt, _conf, false);
             rs = executeQuery(_conf, conn, stmnt, select);
             return getSequence(rs, dict);
         } finally {
@@ -566,6 +569,7 @@
                     appendValue(Numbers.valueOf(cur), _seqColumn);
 
                 stmnt = prepareStatement(conn, upd);
+                dict.setTimeouts(stmnt, _conf, true);
                 updates = executeUpdate(_conf, conn, stmnt, upd, RowImpl.ACTION_UPDATE);
             } finally {
                 if (rs != null) 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ClassNameDiscriminatorStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ClassNameDiscriminatorStrategy.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ClassNameDiscriminatorStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ClassNameDiscriminatorStrategy.java
Tue Mar 17 04:39:56 2009
@@ -24,6 +24,8 @@
 import java.sql.SQLException;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.schema.Column;
@@ -73,9 +75,9 @@
 
         Column col = disc.getColumns()[0];
         DBDictionary dict = store.getDBDictionary();
+        JDBCFetchConfiguration fetch = store.getFetchConfiguration();
         SQLBuffer select = dict.toSelect(new SQLBuffer(dict).append(col),
-            store.getFetchConfiguration(),
-            new SQLBuffer(dict).append(col.getTable()), null, null,
+            fetch, new SQLBuffer(dict).append(col.getTable()), null, null,
             null, null, true, false, 0, Long.MAX_VALUE);
 
         Log log = disc.getMappingRepository().getLog();
@@ -88,6 +90,7 @@
         ResultSet rs = null;
         try {
             stmnt = select.prepareStatement(conn);
+            dict.setTimeouts(stmnt, fetch, false);
             rs = stmnt.executeQuery();
             String className;
             while (rs.next()) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedLobFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedLobFieldStrategy.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedLobFieldStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedLobFieldStrategy.java
Tue Mar 17 04:39:56 2009
@@ -23,6 +23,7 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.JavaSQLTypes;
@@ -142,20 +143,23 @@
 
     public void customUpdate(OpenJPAStateManager sm, JDBCStore store)
         throws SQLException {
+        JDBCFetchConfiguration fetch = store.getFetchConfiguration();
         // select existing value for update
         Column col = field.getColumns()[0];
         Select sel = store.getSQLFactory().newSelect();
         sel.select(col);
         field.wherePrimaryKey(sel, sm, store);
-        SQLBuffer sql = sel.toSelect(true, store.getFetchConfiguration());
+        SQLBuffer sql = sel.toSelect(true, fetch);
 
         Connection conn = store.getConnection();
+        DBDictionary dict = store.getDBDictionary();
         PreparedStatement stmnt = null;
         ResultSet rs = null;
         try {
             stmnt = sql.prepareStatement(conn,
                 ResultSet.TYPE_SCROLL_INSENSITIVE,
                 ResultSet.CONCUR_UPDATABLE);
+            dict.setTimeouts(stmnt, fetch, true);
             rs = stmnt.executeQuery();
             rs.next();
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/TableSchemaFactory.java
Tue Mar 17 04:39:56 2009
@@ -235,7 +235,7 @@
                 + " (" + _pkColumn + ", " + _schemaColumn + ") VALUES (?, ?)");
             dict.setInt(stmnt, 1, 1, _pkColumn);
             dict.setNull(stmnt, 2, _schemaColumn.getType(), _schemaColumn);
-
+            dict.setTimeouts(stmnt, _conf, true);
             stmnt.executeUpdate();
         } finally {
             if (stmnt != null)
@@ -290,6 +290,7 @@
                 conn.setAutoCommit(true);
 
             stmnt = select.prepareStatement(conn);
+            dict.setQueryTimeout(stmnt, _conf.getQueryTimeout());
             rs = stmnt.executeQuery();
             rs.next();
             String schema = (_schemaColumn.getType() == Types.CLOB) ?
@@ -353,12 +354,14 @@
                 else
                     dict.setString(stmnt, 1, schema, _schemaColumn);
                 dict.setInt(stmnt, 2, 1, _pkColumn);
+                dict.setTimeouts(stmnt, _conf, true);
                 stmnt.executeUpdate();
             } else {
                 stmnt = conn.prepareStatement(update,
                     ResultSet.TYPE_SCROLL_INSENSITIVE,
                     ResultSet.CONCUR_UPDATABLE);
                 dict.setInt(stmnt, 1, 1, _pkColumn);
+                dict.setTimeouts(stmnt, _conf, true);
                 rs = stmnt.executeQuery();
                 rs.next();
                 dict.putString(rs.getClob(1), schema);

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Tue Mar 17 04:39:56 2009
@@ -843,6 +843,10 @@
             if (subtype == StoreException.LOCK && errorState.equals("57033")
                 && ex.getMessage().indexOf("80") != -1) {
                 recoverable = Boolean.TRUE;
+            } else if (subtype == StoreException.QUERY && errorState.equals("57014")
+                && ex.getMessage().indexOf("40001") == -1) {
+                // FIXME drwoods - OPENJPA-964 - Need to determine expected DB2 behavior
for query timeouts
+                recoverable = Boolean.TRUE;
             }
         }
         return recoverable;

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Tue Mar 17 04:39:56 2009
@@ -109,6 +109,7 @@
 import org.apache.openjpa.util.ObjectNotFoundException;
 import org.apache.openjpa.util.OpenJPAException;
 import org.apache.openjpa.util.OptimisticException;
+import org.apache.openjpa.util.QueryException;
 import org.apache.openjpa.util.ReferentialIntegrityException;
 import org.apache.openjpa.util.Serialization;
 import org.apache.openjpa.util.StoreException;
@@ -3649,7 +3650,7 @@
                 stmnt.setString(idx++, schemaName.toUpperCase());
             if (sequenceName != null)
                 stmnt.setString(idx++, sequenceName);
-
+            setQueryTimeout(stmnt, conf.getQueryTimeout());
             rs = executeQuery(conn, stmnt, str);
             return getSequence(rs);            
          } finally {
@@ -4046,6 +4047,7 @@
         PreparedStatement stmnt = prepareStatement(conn, query);
         ResultSet rs = null;
         try {
+            setQueryTimeout(stmnt, conf.getQueryTimeout());
             rs = executeQuery(conn, stmnt, query);
             return getKey(rs, col);
         } finally {
@@ -4174,6 +4176,76 @@
     	}
     }
     
+    /**
+     * FIXME - OPENJPA-957 - lockTimeout is a server-side function and
+     * shouldn't be using client-side setQueryTimeout for lock timeouts.
+     * 
+     * This method is to provide override for non-JDBC or JDBC-like 
+     * implementation of setting query and lock timeouts.
+     * 
+     * @param stmnt
+     * @param fetch
+     * @param forUpdate - true if we should also try setting a lock timeout
+     * @throws SQLException
+     */
+    public void setTimeouts(PreparedStatement stmnt, 
+        JDBCFetchConfiguration fetch, boolean forUpdate) throws SQLException {
+        if (this.supportsQueryTimeout) {
+            int timeout = fetch.getQueryTimeout();
+            if (forUpdate) {
+                // if this is a locking select and the lock timeout is greater 
+                // than the configured query timeout, use the lock timeout
+                timeout = Math.max(fetch.getQueryTimeout(), 
+                    fetch.getLockTimeout());
+            }
+            setQueryTimeout(stmnt, timeout);
+        }
+    }
+
+    /**
+     * FIXME - OPENJPA-957 - lockTimeout is a server-side function and
+     * shouldn't be using client-side setQueryTimeout for lock timeouts.
+     * 
+     * This method is to provide override for non-JDBC or JDBC-like 
+     * implementation of setting query and lock timeouts.
+     * 
+     * @param stmnt
+     * @param fetch
+     * @param forUpdate - true if we should also try setting a lock timeout
+     * @throws SQLException
+     */
+    public void setTimeouts(PreparedStatement stmnt, JDBCConfiguration conf,
+        boolean forUpdate) throws SQLException {
+        if (this.supportsQueryTimeout) {
+            int timeout = conf.getQueryTimeout();
+            if (forUpdate) {
+                // if this is a locking select and the lock timeout is greater
+                // than the configured query timeout, use the lock timeout
+                timeout = Math.max(conf.getQueryTimeout(), 
+                    conf.getLockTimeout());
+            }
+            setQueryTimeout(stmnt, timeout);
+        }
+    }
+
+    /**
+     * This method is to provide override for non-JDBC or JDBC-like 
+     * implementation of setting query timeout.
+     */
+    public void setQueryTimeout(PreparedStatement stmnt, int timeout)
+        throws SQLException {
+        if (this.supportsQueryTimeout && timeout >= 0) {
+            if (timeout > 0 && timeout < 1000) {
+                timeout = 1000; 
+                Log log = conf.getLog(JDBCConfiguration.LOG_JDBC);
+                if (log.isWarnEnabled())
+                    log.warn(_loc.get("millis-query-timeout"));
+            }
+            stmnt.setQueryTimeout(timeout / 1000);
+        }
+    }
+
+
     //////////////////////////////////////
     // ConnectionDecorator implementation
     //////////////////////////////////////
@@ -4276,6 +4348,9 @@
         case StoreException.REFERENTIAL_INTEGRITY:
             storeEx = new ReferentialIntegrityException(msg);
             break;
+        case StoreException.QUERY:
+            storeEx = new QueryException(msg);
+            break;
         default:
             storeEx = new StoreException(msg);
         }
@@ -4362,6 +4437,7 @@
             stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(),
                 ResultSet.TYPE_SCROLL_SENSITIVE,
                 ResultSet.CONCUR_UPDATABLE);
+            setTimeouts(stmnt, store.getFetchConfiguration(), true);
             res = stmnt.executeQuery();
             if (!res.next()) {
                 throw new InternalException(_loc.get("stream-exception"));
@@ -4395,6 +4471,7 @@
             stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(),
                 ResultSet.TYPE_SCROLL_SENSITIVE,
                 ResultSet.CONCUR_UPDATABLE);
+            setTimeouts(stmnt, store.getFetchConfiguration(), true);
             res = stmnt.executeQuery();
             if (!res.next()) {
                 throw new InternalException(_loc.get("stream-exception"));

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DerbyDictionary.java
Tue Mar 17 04:39:56 2009
@@ -113,7 +113,7 @@
         int errorCode = ex.getErrorCode();
         if (errorStates.contains(errorState)) {
             recoverable = Boolean.FALSE;
-            if (subtype == StoreException.LOCK && errorCode < 30000) {
+            if ((subtype == StoreException.LOCK || subtype == StoreException.QUERY) &&
errorCode < 30000) {
                 recoverable = Boolean.TRUE;
             }
         }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
Tue Mar 17 04:39:56 2009
@@ -655,7 +655,7 @@
                 setString(stmnt, idx++, schemaName.toUpperCase(), null);
             if (tableName != null)
                 setString(stmnt, idx++, tableName.toUpperCase(), null);
-
+            setTimeouts(stmnt, conf, false);
             rs = stmnt.executeQuery();
             List pkList = new ArrayList();
             while (rs != null && rs.next())
@@ -703,6 +703,7 @@
             if (tableName != null)
                 setString(stmnt, idx++, tableName.toUpperCase(), null);
 
+            setTimeouts(stmnt, conf, false);
             rs = stmnt.executeQuery();
             List idxList = new ArrayList();
             while (rs != null && rs.next())
@@ -769,7 +770,7 @@
                 setString(stmnt, idx++, schemaName.toUpperCase(), null);
             if (tableName != null)
                 setString(stmnt, idx++, tableName.toUpperCase(), null);
-
+            setTimeouts(stmnt, conf, false);
             rs = stmnt.executeQuery();
             List fkList = new ArrayList();
             while (rs != null && rs.next())
@@ -888,6 +889,7 @@
             + ".currval FROM DUAL");
         ResultSet rs = null;
         try {
+            setTimeouts(stmnt, conf, false);
             rs = stmnt.executeQuery();
             rs.next();
             return Numbers.valueOf(rs.getLong(1));

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
Tue Mar 17 04:39:56 2009
@@ -32,6 +32,7 @@
 import java.util.Arrays;
 import java.util.Date;
 
+import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
 import org.apache.openjpa.jdbc.schema.Column;
@@ -382,14 +383,16 @@
     
     private void updatePostgresBlob(Row row, Column col, JDBCStore store,
         Object ob, Select sel) throws SQLException {
-        SQLBuffer sql = sel.toSelect(true, store.getFetchConfiguration());
+        JDBCFetchConfiguration fetch = store.getFetchConfiguration();
+        SQLBuffer sql = sel.toSelect(true, fetch);
         ResultSet res = null;
         DelegatingConnection conn = 
             (DelegatingConnection) store.getConnection();
         PreparedStatement stmnt = null;
         try {
-            stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(),
+            stmnt = sql.prepareStatement(conn, fetch,
                 ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
+            setTimeouts(stmnt, fetch, true);
             res = stmnt.executeQuery();
             if (!res.next()) {
                 throw new InternalException(_loc.get("stream-exception"));
@@ -443,14 +446,16 @@
     }
 
     public void deleteStream(JDBCStore store, Select sel) throws SQLException {
-        SQLBuffer sql = sel.toSelect(true, store.getFetchConfiguration());
+        JDBCFetchConfiguration fetch = store.getFetchConfiguration();
+        SQLBuffer sql = sel.toSelect(true, fetch);
         ResultSet res = null;
         DelegatingConnection conn = 
             (DelegatingConnection) store.getConnection();
         PreparedStatement stmnt = null;
         try {
-            stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(),
+            stmnt = sql.prepareStatement(conn, fetch,
                 ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
+            setTimeouts(stmnt, fetch, true);
             res = stmnt.executeQuery();
             if (!res.next()) {
                 throw new InternalException(_loc.get("stream-exception"));

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLErrorCodeReader.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLErrorCodeReader.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLErrorCodeReader.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLErrorCodeReader.java
Tue Mar 17 04:39:56 2009
@@ -60,7 +60,7 @@
 		storeErrorTypes.put("optimistic", StoreException.OPTIMISTIC);
 		storeErrorTypes.put("referential-integrity",
 				StoreException.REFERENTIAL_INTEGRITY);
-
+		storeErrorTypes.put("query", StoreException.QUERY);
 	}
 	
 	private static final Localizer _loc = 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java
Tue Mar 17 04:39:56 2009
@@ -28,6 +28,7 @@
 import org.apache.openjpa.lib.util.Localizer.Message;
 import org.apache.openjpa.util.LockException;
 import org.apache.openjpa.util.OpenJPAException;
+import org.apache.openjpa.util.QueryException;
 import org.apache.openjpa.util.StoreException;
 
 /**
@@ -130,6 +131,8 @@
         if (storeEx.getSubtype() == StoreException.LOCK) {
             LockException lockEx = (LockException) storeEx;
             lockEx.setLockLevel(level);
+        } else if (storeEx.getSubtype() == StoreException.QUERY) {
+            QueryException QueryEx = (QueryException) storeEx;
         }
         return storeEx;
     }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Tue
Mar 17 04:39:56 2009
@@ -322,6 +322,7 @@
             stmnt = prepareStatement(conn, sql, null, 
                 ResultSet.TYPE_FORWARD_ONLY, 
                 ResultSet.CONCUR_READ_ONLY, false);
+            _dict.setQueryTimeout(stmnt, store.getFetchConfiguration().getQueryTimeout());
             rs = executeQuery(conn, stmnt, sql, false, store);
             return getCount(rs);
         } finally {
@@ -377,7 +378,7 @@
             else
                 stmnt = prepareStatement(conn, sql, null, rsType, -1, false);
             
-            setTimeout(stmnt, forUpdate, fetch);
+            _dict.setTimeouts(stmnt, fetch, forUpdate);
             
             rs = executeQuery(conn, stmnt, sql, isLRS, store);
         } catch (SQLException se) {
@@ -450,27 +451,6 @@
     
     /**
      * This method is to provide override for non-JDBC or JDBC-like 
-     * implementation of setting query timeout.
-     */
-    protected void setTimeout(PreparedStatement stmnt, boolean forUpdate,
-        JDBCFetchConfiguration fetch) throws SQLException {
-        // if this is a locking select and the lock timeout is greater than
-        // the configured query timeout, use the lock timeout
-        if (forUpdate && _dict.supportsQueryTimeout && fetch != null 
-            && fetch.getLockTimeout() > stmnt.getQueryTimeout() * 1000) {
-            int timeout = fetch.getLockTimeout();
-            if (timeout < 1000) {
-                timeout = 1000; 
-                Log log = _conf.getLog(JDBCConfiguration.LOG_JDBC);
-                if (log.isWarnEnabled())
-                    log.warn(_loc.get("millis-query-timeout"));
-            }
-            stmnt.setQueryTimeout(timeout / 1000);
-        }
-    }
-
-    /**
-     * This method is to provide override for non-JDBC or JDBC-like 
      * implementation of executing query.
      */
     protected ResultSet executeQuery(Connection conn, PreparedStatement stmnt, 

Modified: openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml?rev=755113&r1=755112&r2=755113&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-error-state-codes.xml
Tue Mar 17 04:39:56 2009
@@ -29,11 +29,12 @@
 <sql-state-codes>
 
 	<dictionary class="org.apache.openjpa.jdbc.sql.DB2Dictionary">
-		<lock>40001,57033,57014</lock>
+		<lock>40001,57033</lock>
 		<referential-integrity>23502,42912,23001,23504,23511,23512,23513,23515,23520,23505</referential-integrity>
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query>57014</query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.DerbyDictionary">
@@ -42,6 +43,7 @@
 		<object-exists>23505</object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query>XCL52</query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.SQLServerDictionary">
@@ -50,6 +52,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>1205</optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.SybaseDictionary">
@@ -58,6 +61,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>1205</optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.AccessDictionary">
@@ -66,6 +70,7 @@
 		<object-exists>23505,456c</object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>40XL1,40001</optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.CacheDictionary">
@@ -74,6 +79,7 @@
 		<object-exists>23505,456c</object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>40XL1,40001</optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.EmpressDictionary">
@@ -82,6 +88,7 @@
 		<object-exists>23505,456c</object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>40XL1,40001</optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.FoxProDictionary">
@@ -90,6 +97,7 @@
 		<object-exists>23505,456c</object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>40XL1,40001</optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.H2Dictionary">
@@ -98,6 +106,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.HSQLDictionary">
@@ -106,6 +115,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.InformixDictionary">
@@ -114,6 +124,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.InterbaseDictionary">
@@ -122,6 +133,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.FirebirdDictionary">
@@ -130,6 +142,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.JDataStoreDictionary">
@@ -138,6 +151,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.MySQLDictionary">
@@ -146,6 +160,7 @@
 		<object-exists>23000</object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>41000,1205,1213</optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.OracleDictionary">
@@ -154,6 +169,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.PointbaseDictionary">
@@ -162,6 +178,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic></optimistic>
+        <query></query>
 	</dictionary>
 	
 	<dictionary class="org.apache.openjpa.jdbc.sql.PostgresDictionary">
@@ -170,6 +187,7 @@
 		<object-exists></object-exists>
 		<object-not-found></object-not-found>
 		<optimistic>55P03</optimistic>
+        <query></query>
 	</dictionary>
 	
 </sql-state-codes>
\ No newline at end of file



Mime
View raw message