mirror of https://github.com/apache/openjpa.git
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:
parent
14996dfd40
commit
1873fcd368
|
@ -75,6 +75,10 @@ public class MySQLDictionary
|
|||
*/
|
||||
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()";
|
||||
|
@ -416,4 +420,27 @@ public class MySQLDictionary
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue