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.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@920476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-03-08 19:35:47 +00:00
parent 14996dfd40
commit 1873fcd368
1 changed files with 27 additions and 0 deletions

View File

@ -75,6 +75,10 @@ public class MySQLDictionary
*/ */
public boolean optimizeMultiTableDeletes = false; public boolean optimizeMultiTableDeletes = false;
public static final String tinyBlobTypeName = "TINYBLOB";
public static final String mediumBlobTypeName = "MEDIUMBLOB";
public static final String longBlobTypeName = "LONGBLOB";
public MySQLDictionary() { public MySQLDictionary() {
platform = "MySQL"; platform = "MySQL";
validationSQL = "SELECT NOW()"; validationSQL = "SELECT NOW()";
@ -416,4 +420,27 @@ public class MySQLDictionary
} }
return result; return result;
} }
/**
* 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);
}
}
} }