openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtyle...@apache.org
Subject svn commit: r1160003 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: AbstractSQLServerDictionary.java H2Dictionary.java MySQLDictionary.java OracleDictionary.java SQLServerDictionary.java SybaseDictionary.java
Date Sun, 21 Aug 2011 15:34:37 GMT
Author: mtylenda
Date: Sun Aug 21 15:34:37 2011
New Revision: 1160003

URL: http://svn.apache.org/viewvc?rev=1160003&view=rev
Log:
OPENJPA-867: Use 3-argument version of LOCATE-like SQL function where possible, instead of
a trick with SUBSTRING.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.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/SQLServerDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java?rev=1160003&r1=1160002&r2=1160003&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractSQLServerDictionary.java
Sun Aug 21 15:34:37 2011
@@ -136,21 +136,4 @@ public abstract class AbstractSQLServerD
             buf.append(" - 1))");
         }
     }
-
-    public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
-        FilterValue start) {
-        buf.append("(CHARINDEX(");
-        find.appendTo(buf);
-        buf.append(", ");
-        if (start != null)
-            substring(buf, str, start, null);
-        else
-            str.appendTo(buf);
-        buf.append(")");
-        if (start != null) {
-            buf.append(" - 1 + ");
-            start.appendTo(buf);
-        }
-        buf.append(")");
-    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java?rev=1160003&r1=1160002&r2=1160003&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
Sun Aug 21 15:34:37 2011
@@ -229,16 +229,12 @@ public class H2Dictionary extends DBDict
     @Override
     public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
         FilterValue start) {
-        buf.append("(POSITION(");
+        buf.append("LOCATE(");
         find.appendTo(buf);
-        buf.append(" IN ");
-        if (start != null)
-            substring(buf, str, start, null);
-        else
-            str.appendTo(buf);
-        buf.append(")");
+        buf.append(", ");
+        str.appendTo(buf);
         if (start != null) {
-            buf.append(" - 1 + ");
+            buf.append(", ");
             start.appendTo(buf);
         }
         buf.append(")");

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java?rev=1160003&r1=1160002&r2=1160003&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Sun Aug 21 15:34:37 2011
@@ -477,5 +477,19 @@ public class MySQLDictionary
             return super.getTypeName(col);
         }
     }
+
+    @Override
+    public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
+        FilterValue start) {
+        buf.append("LOCATE(");
+        find.appendTo(buf);
+        buf.append(", ");
+        str.appendTo(buf);
+        if (start != null) {
+            buf.append(", ");
+            start.appendTo(buf);
+        }
+        buf.append(")");
+    }
 }
 

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=1160003&r1=1160002&r2=1160003&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
Sun Aug 21 15:34:37 2011
@@ -1416,4 +1416,18 @@ public class OracleDictionary
         }
         return super.getIsNotNullSQL(colAlias, colType);
     }
+
+    @Override
+    public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
+        FilterValue start) {
+        buf.append("INSTR(");
+        str.appendTo(buf);
+        buf.append(", ");
+        find.appendTo(buf);
+        if (start != null) {
+            buf.append(", ");
+            start.appendTo(buf);
+        }
+        buf.append(")");
+    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java?rev=1160003&r1=1160002&r2=1160003&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
Sun Aug 21 15:34:37 2011
@@ -328,4 +328,17 @@ public class SQLServerDictionary extends
         return clob.getCharacterStream();
     }
 
+    @Override
+    public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
+        FilterValue start) {
+        buf.append("CHARINDEX(");
+        find.appendTo(buf);
+        buf.append(", ");
+        str.appendTo(buf);
+        if (start != null) {
+            buf.append(", ");
+            start.appendTo(buf);
+        }
+        buf.append(")");
+    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java?rev=1160003&r1=1160002&r2=1160003&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
Sun Aug 21 15:34:37 2011
@@ -30,6 +30,7 @@ import java.util.Arrays;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
+import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.ForeignKey;
 import org.apache.openjpa.jdbc.schema.Index;
@@ -485,4 +486,20 @@ public class SybaseDictionary
         return identityColumnName;       
     }
 
+    public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
+        FilterValue start) {
+        buf.append("(CHARINDEX(");
+        find.appendTo(buf);
+        buf.append(", ");
+        if (start != null)
+            substring(buf, str, start, null);
+        else
+            str.appendTo(buf);
+        buf.append(")");
+        if (start != null) {
+            buf.append(" - 1 + ");
+            start.appendTo(buf);
+        }
+        buf.append(")");
+    }
 }



Mime
View raw message