openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wisnes...@apache.org
Subject svn commit: r510281 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Wed, 21 Feb 2007 22:50:05 GMT
Author: wisneskid
Date: Wed Feb 21 14:50:04 2007
New Revision: 510281

URL: http://svn.apache.org/viewvc?view=rev&rev=510281
Log:
DB2 Optimize for clause enhancement

Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?view=diff&rev=510281&r1=510280&r2=510281
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Wed Feb 21 14:50:04 2007
@@ -20,6 +20,7 @@
 import java.sql.SQLException;
 import java.util.Arrays;
 
+import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.schema.Sequence;
 
 /**
@@ -33,7 +34,7 @@
         validationSQL = "SELECT DISTINCT(CURRENT TIMESTAMP) FROM "
             + "SYSIBM.SYSTABLES";
         supportsSelectEndIndex = true;
-
+        optimizeClause ="optimize for";
         nextSequenceQuery = "VALUES NEXTVAL FOR {0}";
 
         sequenceSQL = "SELECT SEQSCHEMA AS SEQUENCE_SCHEMA, "
@@ -190,5 +191,21 @@
                 }
             }
     	}
+    }
+    
+    public String getOptimizeClause(JDBCFetchConfiguration fetch) {
+        Integer rows = null;
+        StringBuffer optimizeString = null;
+        if (fetch.getHint("openjpa.hint.optimize") != null) {
+            optimizeString = new StringBuffer();
+            rows = (Integer)fetch.getHint("openjpa.hint.optimize");
+            optimizeString.append(" ").append(optimizeClause).append(" ")
+                .append(rows).append(" ");
+            if(rows.intValue() > 1)
+    		    optimizeString.append(rowsClause).append(" ");
+            else
+    		    optimizeString.append(rowClause).append(" ");
+        }
+        return optimizeString.toString();    
     }
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=510281&r1=510280&r2=510281
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Feb 21 14:50:04 2007
@@ -184,6 +184,9 @@
     public String crossJoinClause = "CROSS JOIN";
     public boolean requiresConditionForCrossJoin = false;
     public String forUpdateClause = "FOR UPDATE";
+    public String optimizeClause = null;
+    public String rowClause = "row";
+    public String rowsClause = "rows";
     public String tableForUpdateClause = null;
     public String distinctCountColumnSeparator = null;
     public boolean supportsSelectForUpdate = true;
@@ -2143,10 +2146,22 @@
         SQLBuffer from, SQLBuffer where, SQLBuffer group,
         SQLBuffer having, SQLBuffer order,
         boolean distinct, boolean forUpdate, long start, long end) {
-        return toOperation(getSelectOperation(fetch), selects, from, where,
+    	
+        String optimizeString = null;
+        SQLBuffer selString = toOperation(getSelectOperation(fetch), 
+            selects, from, where,
             group, having, order, distinct, forUpdate, start, end);
+        if (fetch != null)
+            optimizeString = getOptimizeClause(fetch);
+        if (optimizeString != null)
+            selString.append(optimizeString);
+        return selString;    	
     }
 
+    public String getOptimizeClause(JDBCFetchConfiguration fetch) {
+        return null;    	
+    }
+    
     /**
      * Return the "SELECT" operation clause, adding any available hints, etc.
      */

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?view=diff&rev=510281&r1=510280&r2=510281
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Wed Feb 21 14:50:04 2007
@@ -765,7 +765,7 @@
         }
         if (fetch == null)
             fetch = _fc;
-
+        fetch.setHint("openjpa.hint.optimize", new Integer(1));
         beginOperation(true);
         try {
             assertNontransactionalRead();

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java?view=diff&rev=510281&r1=510280&r2=510281
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java
Wed Feb 21 14:50:04 2007
@@ -279,6 +279,8 @@
      */
     public Object getSingleResult() {
         _em.assertNotCloseInvoked();
+    	_query.getFetchConfiguration().
+    		setHint("openjpa.hint.optimize", new Integer(1));
         Object ob = execute();
         if (!(ob instanceof List))
             return ob;



Mime
View raw message