openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r920475 - /openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Date Mon, 08 Mar 2010 19:35:15 GMT
Author: dwoods
Date: Mon Mar  8 19:35:15 2010
New Revision: 920475

URL: http://svn.apache.org/viewvc?rev=920475&view=rev
Log:
OPENJPA-740 In MySQLDictionary use LONGBLOB, MEDIUMBLOB, TINYBLOB based on the column size,
instead of always using BLOB which can only hold 64KB.  Patch contributed by Simone Gianni.

Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java?rev=920475&r1=920474&r2=920475&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Mon Mar  8 19:35:15 2010
@@ -68,6 +68,11 @@
      */
     public boolean optimizeMultiTableDeletes = false;
 
+    public static final String tinyBlobTypeName = "TINYBLOB";
+    public static final String mediumBlobTypeName = "MEDIUMBLOB";
+    public static final String longBlobTypeName = "LONGBLOB";    
+
+
     public MySQLDictionary() {
         platform = "MySQL";
         validationSQL = "SELECT NOW()";
@@ -379,4 +384,27 @@
             select += " " + hint;
         return select;
     }    
+
+    /**
+     * OPENJPA-740 Special case for MySql special column types,
+     * like LONGTEXT, LONGBLOG etc.. 
+     * @see org.apache.openjpa.jdbc.sql.DBDictionary#getTypeName(org.apache.openjpa.jdbc.schema.Column)
+     */
+    @Override
+    public String getTypeName(Column col) {
+        if (col.getType() == Types.BLOB) {
+            if (col.getSize() <= 255)
+                return tinyBlobTypeName;
+            else if (col.getSize() <= 65535)
+                return blobTypeName;  // old default of 64KB
+            else if (col.getSize() <= 16777215)
+                return mediumBlobTypeName;
+            else
+                return longBlobTypeName;
+        } else {
+            return super.getTypeName(col);
+        }
+    }
+
 }
+



Mime
View raw message