【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-MySQLDialect.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
//$Id: MySQLDialect.java 9101 2006-01-20 17:02:04Z steveebersole $
package org.hibernate.dialect;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.
sql.SQLException;
import java.sql.Types;
import org.hibernate.Hibernate;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.util.StringHelper;
/**
* An SQL dialect for MySQL (prior to 5.x).
*
* @author Gavin King
*/
public class MySQLDialect extends Dialect {
public MySQLDialect() {
super();
registerColumnType( Types.BIT, "bit" );
registerColumnType( Types.BIGINT, "bigint" );
registerColumnType( Types.SMALLINT, "smallint" );
registerColumnType( Types.TINYINT, "tinyint" );
registerColumnType( Types.INTEGER, "integer" );
registerColumnType( Types.CHAR, "char(1)" );
registerColumnType( Types.FLOAT, "float" );
registerColumnType( Types.DOUBLE, "double precision" );
registerColumnType( Types.DATE, "date" );
registerColumnType( Types.TIME, "time" );
registerColumnType( Types.TIMESTAMP, "datetime" );
registerColumnType( Types.VARBINARY, "longblob" );
registerColumnType( Types.VARBINARY, 16777215, "mediumblob" );
registerColumnType( Types.VARBINARY, 65535, "blob" );
registerColumnType( Types.VARBINARY, 255, "tinyblob" );
registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
registerColumnType( Types.BLOB, "longblob" );
registerColumnType( Types.BLOB, 16777215, "mediumblob" );
registerColumnType( Types.BLOB, 65535, "blob" );
registerColumnType( Types.CLOB, "longtext" );
registerColumnType( Types.CLOB, 16777215, "mediumtext" );
registerColumnType( Types.CLOB, 65535, "text" );
registerVarcharTypes();
registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
registerFunction("bin", new StandardSQLFunction("bin", Hibernate.STRING) );
registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.LONG) );
registerFunction("lcase", new StandardSQLFunction("lcase") );
registerFunction("lower", new StandardSQLFunction("lower") );
registerFunction("length", new StandardSQLFunction("length", Hibernate.LONG) );
registerFunction("ltrim", new StandardSQLFunction("ltrim") );
registerFunction("ord", new StandardSQLFunction("ord", Hibernate.INTEGER) );
registerFunction("quote", new StandardSQLFunction("quote") );
registerFunction("reverse", new StandardSQLFunction("reverse") );
registerFunction("rtrim", new StandardSQLFunction("rtrim") );
registerFunction("soundex", new StandardSQLFunction("soundex") );
registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) );
registerFunction("ucase", new StandardSQLFunction("ucase") );
registerFunction("upper", new StandardSQLFunction("upper") );
registerFunction("unhex", new StandardSQLFunction("unhex", Hibernate.STRING) );
registerFunction("abs", new StandardSQLFunction("abs") );
registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
registerFunction("crc32", new StandardSQLFunction("crc32", Hibernate.LONG) );
registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
registerFunction("log2", new StandardSQLFunction("log2", Hibernate.DOUBLE) );
registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
registerFu