Java 类org.hibernate.dialect.function.SQLFunctionTemplate 实例源码

项目:lams    文件:SQLServerDialect.java   
/**
 * Constructs a SQLServerDialect
 */
public SQLServerDialect() {
    registerColumnType( Types.VARBINARY, "image" );
    registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
    registerColumnType( Types.LONGVARBINARY, "image" );
    registerColumnType( Types.LONGVARCHAR, "text" );
    registerColumnType( Types.BOOLEAN, "bit" );

    registerFunction( "second", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(second, ?1)" ) );
    registerFunction( "minute", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(minute, ?1)" ) );
    registerFunction( "hour", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(hour, ?1)" ) );
    registerFunction( "locate", new StandardSQLFunction( "charindex", StandardBasicTypes.INTEGER ) );

    registerFunction( "extract", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(?1, ?3)" ) );
    registerFunction( "mod", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "?1 % ?2" ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datalength(?1) * 8" ) );

    registerFunction( "trim", new AnsiTrimEmulationFunction() );

    registerKeyword( "top" );
}
项目:cacheonix-core    文件:SQLServerDialect.java   
public SQLServerDialect() {
    registerColumnType( Types.VARBINARY, "image" );
    registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );

    registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "datepart(second, ?1)") );
    registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "datepart(minute, ?1)") );
    registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "datepart(hour, ?1)") );
    registerFunction( "locate", new StandardSQLFunction("charindex", Hibernate.INTEGER) );

    registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(?1, ?3)" ) );
    registerFunction( "mod", new SQLFunctionTemplate( Hibernate.INTEGER, "?1 % ?2" ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "datalength(?1) * 8" ) );

    registerFunction( "trim", new AnsiTrimEmulationFunction() );

    registerKeyword("top");
}
项目:sod    文件:SodDB.java   
public static void configHibernate(Configuration config) {
    logger.debug("adding to HibernateUtil   " + configFile);
    config.addResource(configFile, SodDB.class.getClassLoader());
    if(ConnMgr.getURL().startsWith("jdbc:hsql")) {
        config.addSqlFunction("datediff",
                              new SQLFunctionTemplate(org.hibernate.type.StandardBasicTypes.LONG,
                                                      "datediff(?1, ?2, ?3)"));
        config.addSqlFunction("milliseconds_between",
                              new SQLFunctionTemplate(org.hibernate.type.StandardBasicTypes.LONG,
                                                      "datediff('ms', ?1, ?2)"));
        config.addSqlFunction("seconds_between",
                              new SQLFunctionTemplate(org.hibernate.type.StandardBasicTypes.LONG,
                                                      "datediff('ss', ?1, ?2)"));
    } else if(ConnMgr.getURL().startsWith("jdbc:postgresql")) {
        config.addSqlFunction("milliseconds_between",
                              new SQLFunctionTemplate(org.hibernate.type.StandardBasicTypes.LONG,
                                                      "extract(epoch from (?2 - ?1)) * 1000"));
        config.addSqlFunction("seconds_between",
                              new SQLFunctionTemplate(org.hibernate.type.StandardBasicTypes.LONG,
                                                      "extract(epoch from (?2 - ?1))"));
    }
}
项目:amv-access-api-poc    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StringType.INSTANCE, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
    registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));
}
项目:amv-access-api-poc    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StringType.INSTANCE, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
    registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));
}
项目:ApplicationDetection    文件:SqliteDialect.java   
public SqliteDialect() {
    super();
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");
    registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(IntegerType.INSTANCE, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
    registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));
}
项目:lams    文件:SybaseASE157Dialect.java   
/**
 * Constructs a SybaseASE157Dialect
 */
public SybaseASE157Dialect() {
    super();

    registerFunction( "create_locator", new SQLFunctionTemplate( StandardBasicTypes.BINARY, "create_locator(?1, ?2)" ) );
    registerFunction( "locator_literal", new SQLFunctionTemplate( StandardBasicTypes.BINARY, "locator_literal(?1, ?2)" ) );
    registerFunction( "locator_valid", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "locator_valid(?1)" ) );
    registerFunction( "return_lob", new SQLFunctionTemplate( StandardBasicTypes.BINARY, "return_lob(?1, ?2)" ) );
    registerFunction( "setdata", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "setdata(?1, ?2, ?3)" ) );
    registerFunction( "charindex", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "charindex(?1, ?2, ?3)" ) );
}
项目:unitimes    文件:HibernateUtil.java   
public static void addBitwiseOperationsToDialect() {
    SessionFactoryImplementor hibSessionFactory = (SessionFactoryImplementor)new _RootDAO().getSession().getSessionFactory();
    Dialect dialect = hibSessionFactory.getDialect();
    if (!dialect.getFunctions().containsKey("bit_and")) {
        if (isOracle())
            dialect.getFunctions().put("bit_and", new StandardSQLFunction("bitand", IntegerType.INSTANCE));  
        else
            dialect.getFunctions().put("bit_and", new SQLFunctionTemplate(IntegerType.INSTANCE, "?1 & ?2"));
    }
}
项目:dswork    文件:SQLiteDialect.java   
public SQLiteDialect()
{
    super();
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");
    registerFunction("concat", new VarArgsSQLFunction(new StringType(), "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(new IntegerType(), "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", new StringType()));
    registerFunction("substring", new StandardSQLFunction("substr", new StringType()));
}
项目:openbravo-brazil    文件:APRMApplicationInitializer.java   
@Override
public void initialize() {
  OBDal.getInstance().registerSQLFunction("ad_message_get2",
      new StandardSQLFunction("ad_message_get2", StandardBasicTypes.STRING));
  OBDal.getInstance().registerSQLFunction("hqlagg",
      new SQLFunctionTemplate(StandardBasicTypes.STRING, getAggregationSQL()));
  OBDal.getInstance().registerSQLFunction("get_uuid",
      new StandardSQLFunction("get_uuid", StandardBasicTypes.STRING));
}
项目:CloudRaid-DesktopApp    文件:SQLiteDialect.java   
public SQLiteDialect() {

        super();
        registerColumnType(Types.BIT, "integer");
        registerColumnType(Types.TINYINT, "tinyint");
        registerColumnType(Types.SMALLINT, "smallint");
        registerColumnType(Types.INTEGER, "integer");
        registerColumnType(Types.BIGINT, "bigint");
        registerColumnType(Types.FLOAT, "float");
        registerColumnType(Types.REAL, "real");
        registerColumnType(Types.DOUBLE, "double");
        registerColumnType(Types.NUMERIC, "numeric");
        registerColumnType(Types.DECIMAL, "decimal");
        registerColumnType(Types.CHAR, "char");
        registerColumnType(Types.VARCHAR, "varchar");
        registerColumnType(Types.LONGVARCHAR, "longvarchar");
        registerColumnType(Types.DATE, "date");
        registerColumnType(Types.TIME, "time");
        registerColumnType(Types.TIMESTAMP, "timestamp");
        registerColumnType(Types.BINARY, "blob");
        registerColumnType(Types.VARBINARY, "blob");
        registerColumnType(Types.LONGVARBINARY, "blob");
        // registerColumnType(Types.NULL, "null");
        registerColumnType(Types.BLOB, "blob");
        registerColumnType(Types.CLOB, "clob");
        registerColumnType(Types.BOOLEAN, "integer");

        registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "",
                "||", ""));
        registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER,
                "?1 % ?2"));
        registerFunction("substr", new StandardSQLFunction("substr",
                StandardBasicTypes.STRING));
        registerFunction("substring", new StandardSQLFunction("substr",
                StandardBasicTypes.STRING));
    }
项目:sparrow    文件:SQLiteDialect.java   
public SQLiteDialect() {
  registerColumnType(Types.BIT, "integer");
  registerColumnType(Types.TINYINT, "tinyint");
  registerColumnType(Types.SMALLINT, "smallint");
  registerColumnType(Types.INTEGER, "integer");
  registerColumnType(Types.BIGINT, "bigint");
  registerColumnType(Types.FLOAT, "float");
  registerColumnType(Types.REAL, "real");
  registerColumnType(Types.DOUBLE, "double");
  registerColumnType(Types.NUMERIC, "numeric");
  registerColumnType(Types.DECIMAL, "decimal");
  registerColumnType(Types.CHAR, "char");
  registerColumnType(Types.VARCHAR, "varchar");
  registerColumnType(Types.LONGVARCHAR, "longvarchar");
  registerColumnType(Types.DATE, "date");
  registerColumnType(Types.TIME, "time");
  registerColumnType(Types.TIMESTAMP, "timestamp");
  registerColumnType(Types.BINARY, "blob");
  registerColumnType(Types.VARBINARY, "blob");
  registerColumnType(Types.LONGVARBINARY, "blob");
  // registerColumnType(Types.NULL, "null");
  registerColumnType(Types.BLOB, "blob");
  registerColumnType(Types.CLOB, "clob");
  registerColumnType(Types.BOOLEAN, "integer");

  registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") );
  registerFunction( "mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2" ) );
  registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
  registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
}
项目:FirefightersCenter    文件:SQLiteDialect.java   
public SQLiteDialect() {
  registerColumnType(Types.BIT, "integer");
  registerColumnType(Types.TINYINT, "tinyint");
  registerColumnType(Types.SMALLINT, "smallint");
  registerColumnType(Types.INTEGER, "integer");
  registerColumnType(Types.BIGINT, "bigint");
  registerColumnType(Types.FLOAT, "float");
  registerColumnType(Types.REAL, "real");
  registerColumnType(Types.DOUBLE, "double");
  registerColumnType(Types.NUMERIC, "numeric");
  registerColumnType(Types.DECIMAL, "decimal");
  registerColumnType(Types.CHAR, "char");
  registerColumnType(Types.VARCHAR, "varchar");
  registerColumnType(Types.LONGVARCHAR, "longvarchar");
  registerColumnType(Types.DATE, "date");
  registerColumnType(Types.TIME, "time");
  registerColumnType(Types.TIMESTAMP, "timestamp");
  registerColumnType(Types.BINARY, "blob");
  registerColumnType(Types.VARBINARY, "blob");
  registerColumnType(Types.LONGVARBINARY, "blob");
  // registerColumnType(Types.NULL, "null");
  registerColumnType(Types.BLOB, "blob");
  registerColumnType(Types.CLOB, "clob");
  registerColumnType(Types.BOOLEAN, "integer");

  registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
  registerFunction("mod", new SQLFunctionTemplate(IntegerType.INSTANCE, "?1 % ?2"));
  registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
  registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));
}
项目:webdsl    文件:SQLiteDialect.java   
public SQLiteDialect() {
    super();
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "",
            "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER,
            "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr",
            StandardBasicTypes.STRING));
    registerFunction("substring", new StandardSQLFunction("substr",
            StandardBasicTypes.STRING));
}
项目:unitime    文件:HibernateUtil.java   
public static void addBitwiseOperationsToDialect() {
    SessionFactoryImplementor hibSessionFactory = (SessionFactoryImplementor)new _RootDAO().getSession().getSessionFactory();
    Dialect dialect = hibSessionFactory.getDialect();
    if (!dialect.getFunctions().containsKey("bit_and")) {
        if (isOracle())
            dialect.getFunctions().put("bit_and", new StandardSQLFunction("bitand", IntegerType.INSTANCE));  
        else
            dialect.getFunctions().put("bit_and", new SQLFunctionTemplate(IntegerType.INSTANCE, "?1 & ?2"));
    }
}
项目:Introspect-Framework    文件:SQLiteDialect.java   
public SQLiteDialect() {
registerColumnType(Types.BIT, "boolean");
//registerColumnType(Types.TINYINT, "tinyint");
//registerColumnType(Types.SMALLINT, "smallint");
//registerColumnType(Types.INTEGER, "integer");
//registerColumnType(Types.BIGINT, "bigint");
//registerColumnType(Types.FLOAT, "float");
//registerColumnType(Types.REAL, "real");
//registerColumnType(Types.DOUBLE, "double");
//registerColumnType(Types.NUMERIC, "numeric($p, $s)");
registerColumnType(Types.DECIMAL, "decimal");
registerColumnType(Types.CHAR, "char");
registerColumnType(Types.VARCHAR, "varchar($l)");
registerColumnType(Types.LONGVARCHAR, "longvarchar");
//registerColumnType(Types.DATE, "date");
//registerColumnType(Types.TIME, "time");
registerColumnType(Types.TIMESTAMP, "datetime");
registerColumnType(Types.BINARY, "blob");
registerColumnType(Types.VARBINARY, "blob");
registerColumnType(Types.LONGVARBINARY, "blob");
//registerColumnType(Types.BLOB, "blob");
//registerColumnType(Types.CLOB, "clob");
//registerColumnType(Types.BOOLEAN, "boolean");

registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") );
registerFunction( "mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2" ) );
registerFunction( "quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING) );
registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER) );
registerFunction( "round", new StandardSQLFunction("round") );
registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );}
项目:poli-libras    文件:SQLiteDialect.java   
public SQLiteDialect() {
    super();
    registerColumnType(Types.BIT, "integer");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

     registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
     registerFunction( "mod", new SQLFunctionTemplate( Hibernate.INTEGER, "?1 % ?2" ) );
     registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
     registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
}
项目:sqlite-dialect    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "boolean");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric($p, $s)");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "datetime");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "boolean");

    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2"));
    registerFunction("quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING));
    registerFunction("random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER));
    registerFunction("round", new StandardSQLFunction("round"));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("trim", new AbstractAnsiTrimEmulationFunction() {
        protected SQLFunction resolveBothSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
        }

        protected SQLFunction resolveBothSpaceTrimFromFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)");
        }

        protected SQLFunction resolveLeadingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)");
        }

        protected SQLFunction resolveTrailingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)");
        }

        protected SQLFunction resolveBothTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)");
        }

        protected SQLFunction resolveLeadingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)");
        }

        protected SQLFunction resolveTrailingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
        }
    });
}
项目:lams    文件:TeradataDialect.java   
/**
 * Constructor
 */
public TeradataDialect() {
    super();
    //registerColumnType data types
    registerColumnType( Types.NUMERIC, "NUMERIC($p,$s)" );
    registerColumnType( Types.DOUBLE, "DOUBLE PRECISION" );
    registerColumnType( Types.BIGINT, "NUMERIC(18,0)" );
    registerColumnType( Types.BIT, "BYTEINT" );
    registerColumnType( Types.TINYINT, "BYTEINT" );
    registerColumnType( Types.VARBINARY, "VARBYTE($l)" );
    registerColumnType( Types.BINARY, "BYTEINT" );
    registerColumnType( Types.LONGVARCHAR, "LONG VARCHAR" );
    registerColumnType( Types.CHAR, "CHAR(1)" );
    registerColumnType( Types.DECIMAL, "DECIMAL" );
    registerColumnType( Types.INTEGER, "INTEGER" );
    registerColumnType( Types.SMALLINT, "SMALLINT" );
    registerColumnType( Types.FLOAT, "FLOAT" );
    registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
    registerColumnType( Types.DATE, "DATE" );
    registerColumnType( Types.TIME, "TIME" );
    registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
    // hibernate seems to ignore this type...
    registerColumnType( Types.BOOLEAN, "BYTEINT" );
    registerColumnType( Types.BLOB, "BLOB" );
    registerColumnType( Types.CLOB, "CLOB" );

    registerFunction( "year", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "extract(year from ?1)" ) );
    registerFunction( "length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "character_length(?1)" ) );
    registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
    registerFunction( "substring", new SQLFunctionTemplate( StandardBasicTypes.STRING, "substring(?1 from ?2 for ?3)" ) );
    registerFunction( "locate", new SQLFunctionTemplate( StandardBasicTypes.STRING, "position(?1 in ?2)" ) );
    registerFunction( "mod", new SQLFunctionTemplate( StandardBasicTypes.STRING, "?1 mod ?2" ) );
    registerFunction( "str", new SQLFunctionTemplate( StandardBasicTypes.STRING, "cast(?1 as varchar(255))" ) );

    // bit_length feels a bit broken to me. We have to cast to char in order to
    // pass when a numeric value is supplied. But of course the answers given will
    // be wildly different for these two datatypes. 1234.5678 will be 9 bytes as
    // a char string but will be 8 or 16 bytes as a true numeric.
    // Jay Nance 2006-09-22
    registerFunction(
            "bit_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "octet_length(cast(?1 as char))*4" )
    );

    // The preference here would be
    //   SQLFunctionTemplate( StandardBasicTypes.TIMESTAMP, "current_timestamp(?1)", false)
    // but this appears not to work.
    // Jay Nance 2006-09-22
    registerFunction( "current_timestamp", new SQLFunctionTemplate( StandardBasicTypes.TIMESTAMP, "current_timestamp" ) );
    registerFunction( "current_time", new SQLFunctionTemplate( StandardBasicTypes.TIMESTAMP, "current_time" ) );
    registerFunction( "current_date", new SQLFunctionTemplate( StandardBasicTypes.TIMESTAMP, "current_date" ) );
    // IBID for current_time and current_date

    registerKeyword( "password" );
    registerKeyword( "type" );
    registerKeyword( "title" );
    registerKeyword( "year" );
    registerKeyword( "month" );
    registerKeyword( "summary" );
    registerKeyword( "alias" );
    registerKeyword( "value" );
    registerKeyword( "first" );
    registerKeyword( "role" );
    registerKeyword( "account" );
    registerKeyword( "class" );

    // Tell hibernate to use getBytes instead of getBinaryStream
    getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
    // No batch statements
    getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
项目:lams    文件:Oracle8iDialect.java   
protected void registerFunctions() {
    registerFunction( "abs", new StandardSQLFunction("abs") );
    registerFunction( "sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER) );

    registerFunction( "acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE) );
    registerFunction( "asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE) );
    registerFunction( "atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE) );
    registerFunction( "bitand", new StandardSQLFunction("bitand") );
    registerFunction( "cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE) );
    registerFunction( "cosh", new StandardSQLFunction("cosh", StandardBasicTypes.DOUBLE) );
    registerFunction( "exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE) );
    registerFunction( "ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE) );
    registerFunction( "sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE) );
    registerFunction( "sinh", new StandardSQLFunction("sinh", StandardBasicTypes.DOUBLE) );
    registerFunction( "stddev", new StandardSQLFunction("stddev", StandardBasicTypes.DOUBLE) );
    registerFunction( "sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE) );
    registerFunction( "tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE) );
    registerFunction( "tanh", new StandardSQLFunction("tanh", StandardBasicTypes.DOUBLE) );
    registerFunction( "variance", new StandardSQLFunction("variance", StandardBasicTypes.DOUBLE) );

    registerFunction( "round", new StandardSQLFunction("round") );
    registerFunction( "trunc", new StandardSQLFunction("trunc") );
    registerFunction( "ceil", new StandardSQLFunction("ceil") );
    registerFunction( "floor", new StandardSQLFunction("floor") );

    registerFunction( "chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER) );
    registerFunction( "initcap", new StandardSQLFunction("initcap") );
    registerFunction( "lower", new StandardSQLFunction("lower") );
    registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
    registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
    registerFunction( "soundex", new StandardSQLFunction("soundex") );
    registerFunction( "upper", new StandardSQLFunction("upper") );
    registerFunction( "ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER) );

    registerFunction( "to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) );
    registerFunction( "to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP) );

    registerFunction( "current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false) );
    registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIME, false) );
    registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false) );

    registerFunction( "last_day", new StandardSQLFunction("last_day", StandardBasicTypes.DATE) );
    registerFunction( "sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.DATE, false) );
    registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", StandardBasicTypes.TIMESTAMP, false) );
    registerFunction( "uid", new NoArgSQLFunction("uid", StandardBasicTypes.INTEGER, false) );
    registerFunction( "user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false) );

    registerFunction( "rowid", new NoArgSQLFunction("rowid", StandardBasicTypes.LONG, false) );
    registerFunction( "rownum", new NoArgSQLFunction("rownum", StandardBasicTypes.LONG, false) );

    // Multi-param string dialect functions...
    registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") );
    registerFunction( "instr", new StandardSQLFunction("instr", StandardBasicTypes.INTEGER) );
    registerFunction( "instrb", new StandardSQLFunction("instrb", StandardBasicTypes.INTEGER) );
    registerFunction( "lpad", new StandardSQLFunction("lpad", StandardBasicTypes.STRING) );
    registerFunction( "replace", new StandardSQLFunction("replace", StandardBasicTypes.STRING) );
    registerFunction( "rpad", new StandardSQLFunction("rpad", StandardBasicTypes.STRING) );
    registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
    registerFunction( "substrb", new StandardSQLFunction("substrb", StandardBasicTypes.STRING) );
    registerFunction( "translate", new StandardSQLFunction("translate", StandardBasicTypes.STRING) );

    registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
    registerFunction( "locate", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "instr(?2,?1)" ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "vsize(?1)*8" ) );
    registerFunction( "coalesce", new NvlFunction() );

    // Multi-param numeric dialect functions...
    registerFunction( "atan2", new StandardSQLFunction("atan2", StandardBasicTypes.FLOAT) );
    registerFunction( "log", new StandardSQLFunction("log", StandardBasicTypes.INTEGER) );
    registerFunction( "mod", new StandardSQLFunction("mod", StandardBasicTypes.INTEGER) );
    registerFunction( "nvl", new StandardSQLFunction("nvl") );
    registerFunction( "nvl2", new StandardSQLFunction("nvl2") );
    registerFunction( "power", new StandardSQLFunction("power", StandardBasicTypes.FLOAT) );

    // Multi-param date dialect functions...
    registerFunction( "add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE) );
    registerFunction( "months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT) );
    registerFunction( "next_day", new StandardSQLFunction("next_day", StandardBasicTypes.DATE) );

    registerFunction( "str", new StandardSQLFunction("to_char", StandardBasicTypes.STRING) );
}
项目:lams    文件:AbstractTransactSQLDialect.java   
public AbstractTransactSQLDialect() {
    super();
    registerColumnType( Types.BINARY, "binary($l)" );
    registerColumnType( Types.BIT, "tinyint" );
    registerColumnType( Types.BIGINT, "numeric(19,0)" );
    registerColumnType( Types.SMALLINT, "smallint" );
    registerColumnType( Types.TINYINT, "smallint" );
    registerColumnType( Types.INTEGER, "int" );
    registerColumnType( Types.CHAR, "char(1)" );
    registerColumnType( Types.VARCHAR, "varchar($l)" );
    registerColumnType( Types.FLOAT, "float" );
    registerColumnType( Types.DOUBLE, "double precision" );
    registerColumnType( Types.DATE, "datetime" );
    registerColumnType( Types.TIME, "datetime" );
    registerColumnType( Types.TIMESTAMP, "datetime" );
    registerColumnType( Types.VARBINARY, "varbinary($l)" );
    registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
    registerColumnType( Types.BLOB, "image" );
    registerColumnType( Types.CLOB, "text" );

    registerFunction( "ascii", new StandardSQLFunction( "ascii", StandardBasicTypes.INTEGER ) );
    registerFunction( "char", new StandardSQLFunction( "char", StandardBasicTypes.CHARACTER ) );
    registerFunction( "len", new StandardSQLFunction( "len", StandardBasicTypes.LONG ) );
    registerFunction( "lower", new StandardSQLFunction( "lower" ) );
    registerFunction( "upper", new StandardSQLFunction( "upper" ) );
    registerFunction( "str", new StandardSQLFunction( "str", StandardBasicTypes.STRING ) );
    registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
    registerFunction( "rtrim", new StandardSQLFunction( "rtrim" ) );
    registerFunction( "reverse", new StandardSQLFunction( "reverse" ) );
    registerFunction( "space", new StandardSQLFunction( "space", StandardBasicTypes.STRING ) );

    registerFunction( "user", new NoArgSQLFunction( "user", StandardBasicTypes.STRING ) );

    registerFunction( "current_timestamp", new NoArgSQLFunction( "getdate", StandardBasicTypes.TIMESTAMP ) );
    registerFunction( "current_time", new NoArgSQLFunction( "getdate", StandardBasicTypes.TIME ) );
    registerFunction( "current_date", new NoArgSQLFunction( "getdate", StandardBasicTypes.DATE ) );

    registerFunction( "getdate", new NoArgSQLFunction( "getdate", StandardBasicTypes.TIMESTAMP ) );
    registerFunction( "getutcdate", new NoArgSQLFunction( "getutcdate", StandardBasicTypes.TIMESTAMP ) );
    registerFunction( "day", new StandardSQLFunction( "day", StandardBasicTypes.INTEGER ) );
    registerFunction( "month", new StandardSQLFunction( "month", StandardBasicTypes.INTEGER ) );
    registerFunction( "year", new StandardSQLFunction( "year", StandardBasicTypes.INTEGER ) );
    registerFunction( "datename", new StandardSQLFunction( "datename", StandardBasicTypes.STRING ) );

    registerFunction( "abs", new StandardSQLFunction( "abs" ) );
    registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) );

    registerFunction( "acos", new StandardSQLFunction( "acos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "asin", new StandardSQLFunction( "asin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "atan", new StandardSQLFunction( "atan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "cos", new StandardSQLFunction( "cos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "cot", new StandardSQLFunction( "cot", StandardBasicTypes.DOUBLE ) );
    registerFunction( "exp", new StandardSQLFunction( "exp", StandardBasicTypes.DOUBLE ) );
    registerFunction( "log", new StandardSQLFunction( "log", StandardBasicTypes.DOUBLE ) );
    registerFunction( "log10", new StandardSQLFunction( "log10", StandardBasicTypes.DOUBLE ) );
    registerFunction( "sin", new StandardSQLFunction( "sin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "sqrt", new StandardSQLFunction( "sqrt", StandardBasicTypes.DOUBLE ) );
    registerFunction( "tan", new StandardSQLFunction( "tan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "pi", new NoArgSQLFunction( "pi", StandardBasicTypes.DOUBLE ) );
    registerFunction( "square", new StandardSQLFunction( "square" ) );
    registerFunction( "rand", new StandardSQLFunction( "rand", StandardBasicTypes.FLOAT ) );

    registerFunction( "radians", new StandardSQLFunction( "radians", StandardBasicTypes.DOUBLE ) );
    registerFunction( "degrees", new StandardSQLFunction( "degrees", StandardBasicTypes.DOUBLE ) );

    registerFunction( "round", new StandardSQLFunction( "round" ) );
    registerFunction( "ceiling", new StandardSQLFunction( "ceiling" ) );
    registerFunction( "floor", new StandardSQLFunction( "floor" ) );

    registerFunction( "isnull", new StandardSQLFunction( "isnull" ) );

    registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "+", ")" ) );

    registerFunction( "length", new StandardSQLFunction( "len", StandardBasicTypes.INTEGER ) );
    registerFunction( "trim", new SQLFunctionTemplate( StandardBasicTypes.STRING, "ltrim(rtrim(?1))" ) );
    registerFunction( "locate", new CharIndexFunction() );

    getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
项目:JavaEE    文件:SQLiteDialect.java   
public SQLiteDialect() {
  registerColumnType(Types.BIT, "boolean");
  registerColumnType(Types.TINYINT, "tinyint");
  registerColumnType(Types.SMALLINT, "smallint");
  registerColumnType(Types.INTEGER, "integer");
  registerColumnType(Types.BIGINT, "bigint");
  registerColumnType(Types.FLOAT, "float");
  registerColumnType(Types.REAL, "real");
  registerColumnType(Types.DOUBLE, "double");
  registerColumnType(Types.NUMERIC, "numeric($p, $s)");
  registerColumnType(Types.DECIMAL, "decimal");
  registerColumnType(Types.CHAR, "char");
  registerColumnType(Types.VARCHAR, "varchar($l)");
  registerColumnType(Types.LONGVARCHAR, "longvarchar");
  registerColumnType(Types.DATE, "date");
  registerColumnType(Types.TIME, "time");
  registerColumnType(Types.TIMESTAMP, "datetime");
  registerColumnType(Types.BINARY, "blob");
  registerColumnType(Types.VARBINARY, "blob");
  registerColumnType(Types.LONGVARBINARY, "blob");
  registerColumnType(Types.BLOB, "blob");
  registerColumnType(Types.CLOB, "clob");
  registerColumnType(Types.BOOLEAN, "boolean");

  //registerFunction( "abs", new StandardSQLFunction("abs") );
  registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") );
  //registerFunction( "length", new StandardSQLFunction("length", StandardBasicTypes.LONG) );
  //registerFunction( "lower", new StandardSQLFunction("lower") );
  registerFunction( "mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2" ) );
  registerFunction( "quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING) );
  registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER) );
  registerFunction( "round", new StandardSQLFunction("round") );
  registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
  registerFunction( "substring", new SQLFunctionTemplate( StandardBasicTypes.STRING, "substr(?1, ?2, ?3)" ) );
  registerFunction( "trim", new AbstractAnsiTrimEmulationFunction() {
      protected SQLFunction resolveBothSpaceTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
      }

      protected SQLFunction resolveBothSpaceTrimFromFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)");
      }

      protected SQLFunction resolveLeadingSpaceTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)");
      }

      protected SQLFunction resolveTrailingSpaceTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)");
      }

      protected SQLFunction resolveBothTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)");
      }

      protected SQLFunction resolveLeadingTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)");
      }

      protected SQLFunction resolveTrailingTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
      }
  } );
  //registerFunction( "upper", new StandardSQLFunction("upper") );
}
项目:ctsms    文件:PostgreSQLDialect.java   
public PostgreSQLDialect() {
    super();
    registerFunction("minute", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(minute from ?1)"));
    registerFunction("hour", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(hour from ?1)"));
}
项目:hibernate4-sqlite-dialect    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "boolean");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric($p, $s)");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "datetime");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "boolean");

    registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") );
    registerFunction( "mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2" ) );
    registerFunction( "quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING) );
    registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER) );
    registerFunction( "round", new StandardSQLFunction("round") );
    registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
    registerFunction( "trim", new AbstractAnsiTrimEmulationFunction() {
        protected SQLFunction resolveBothSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
        }

        protected SQLFunction resolveBothSpaceTrimFromFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)");
        }

        protected SQLFunction resolveLeadingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)");
        }

        protected SQLFunction resolveTrailingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)");
        }

        protected SQLFunction resolveBothTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)");
        }

        protected SQLFunction resolveLeadingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)");
        }

        protected SQLFunction resolveTrailingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
        }
    } );
    uniqueDelegate = new SQLiteUniqueDelegate( this );
}
项目:Projeto-Flash    文件:SQLiteDialect.java   
public SQLiteDialect() {
  registerColumnType(Types.BIT, "boolean");
  registerColumnType(Types.TINYINT, "tinyint");
  registerColumnType(Types.SMALLINT, "smallint");
  registerColumnType(Types.INTEGER, "integer");
  registerColumnType(Types.BIGINT, "bigint");
  registerColumnType(Types.FLOAT, "float");
  registerColumnType(Types.REAL, "real");
  registerColumnType(Types.DOUBLE, "double");
  registerColumnType(Types.NUMERIC, "numeric($p, $s)");
  registerColumnType(Types.DECIMAL, "decimal");
  registerColumnType(Types.CHAR, "char");
  registerColumnType(Types.VARCHAR, "varchar($l)");
  registerColumnType(Types.LONGVARCHAR, "longvarchar");
  registerColumnType(Types.DATE, "date");
  registerColumnType(Types.TIME, "time");
  registerColumnType(Types.TIMESTAMP, "datetime");
  registerColumnType(Types.BINARY, "blob");
  registerColumnType(Types.VARBINARY, "blob");
  registerColumnType(Types.LONGVARBINARY, "blob");
  registerColumnType(Types.BLOB, "blob");
  registerColumnType(Types.CLOB, "clob");
  registerColumnType(Types.BOOLEAN, "boolean");

  //registerFunction( "abs", new StandardSQLFunction("abs") );
  registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") );
  //registerFunction( "length", new StandardSQLFunction("length", StandardBasicTypes.LONG) );
  //registerFunction( "lower", new StandardSQLFunction("lower") );
  registerFunction( "mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2" ) );
  registerFunction( "quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING) );
  registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER) );
  registerFunction( "round", new StandardSQLFunction("round") );
  registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
  registerFunction( "substring", new SQLFunctionTemplate( StandardBasicTypes.STRING, "substr(?1, ?2, ?3)" ) );
  registerFunction( "trim", new AbstractAnsiTrimEmulationFunction() {
      protected SQLFunction resolveBothSpaceTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
      }

      protected SQLFunction resolveBothSpaceTrimFromFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)");
      }

      protected SQLFunction resolveLeadingSpaceTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)");
      }

      protected SQLFunction resolveTrailingSpaceTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)");
      }

      protected SQLFunction resolveBothTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)");
      }

      protected SQLFunction resolveLeadingTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)");
      }

      protected SQLFunction resolveTrailingTrimFunction() {
        return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
      }
  } );
  //registerFunction( "upper", new StandardSQLFunction("upper") );
}
项目:vsDiaryWriter    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "boolean");
    // registerColumnType(Types.TINYINT, "tinyint");
    // registerColumnType(Types.SMALLINT, "smallint");
    // registerColumnType(Types.INTEGER, "integer");
    // registerColumnType(Types.BIGINT, "bigint");
    // registerColumnType(Types.FLOAT, "float");
    // registerColumnType(Types.REAL, "real");
    // registerColumnType(Types.DOUBLE, "double");
    // registerColumnType(Types.NUMERIC, "numeric($p, $s)");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    // registerColumnType(Types.DATE, "date");
    // registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "datetime");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.BLOB, "blob");
    // registerColumnType(Types.CLOB, "clob");
    // registerColumnType(Types.BOOLEAN, "boolean");

    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2"));
    registerFunction("quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING));
    registerFunction("random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER));
    registerFunction("round", new StandardSQLFunction("round"));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("trim", new AbstractAnsiTrimEmulationFunction() {
        @Override
        protected SQLFunction resolveBothSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
        }

        @Override
        protected SQLFunction resolveBothSpaceTrimFromFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)");
        }

        @Override
        protected SQLFunction resolveLeadingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)");
        }

        @Override
        protected SQLFunction resolveTrailingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)");
        }

        @Override
        protected SQLFunction resolveBothTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)");
        }

        @Override
        protected SQLFunction resolveLeadingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)");
        }

        @Override
        protected SQLFunction resolveTrailingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
        }
    });
    uniqueDelegate = new SQLiteUniqueDelegate(this);
}
项目:alpha-umi    文件:AppMySQLDialect.java   
public AppMySQLDialect() {
    super();
    registerFunction("regexp", new SQLFunctionTemplate(IntegerType.INSTANCE, "?1 regexp ?2"));
}
项目:cacheonix-core    文件:TeradataDialect.java   
/**
 * Constructor
 */
public TeradataDialect() {
    super();
    //registerColumnType data types
    registerColumnType( Types.NUMERIC, "NUMERIC($p,$s)" );
    registerColumnType( Types.DOUBLE, "DOUBLE PRECISION" );
    registerColumnType( Types.BIGINT, "NUMERIC(18,0)" );
    registerColumnType( Types.BIT, "BYTEINT" );
    registerColumnType( Types.TINYINT, "BYTEINT" );
    registerColumnType( Types.VARBINARY, "VARBYTE($l)" );
    registerColumnType( Types.BINARY, "BYTEINT" );
    registerColumnType( Types.LONGVARCHAR, "LONG VARCHAR" );
    registerColumnType( Types.CHAR, "CHAR(1)" );
    registerColumnType( Types.DECIMAL, "DECIMAL" );
    registerColumnType( Types.INTEGER, "INTEGER" );
    registerColumnType( Types.SMALLINT, "SMALLINT" );
    registerColumnType( Types.FLOAT, "FLOAT" );
    registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
    registerColumnType( Types.DATE, "DATE" );
    registerColumnType( Types.TIME, "TIME" );
    registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
    registerColumnType( Types.BOOLEAN, "BYTEINT" );  // hibernate seems to ignore this type...
    registerColumnType( Types.BLOB, "BLOB" );
    registerColumnType( Types.CLOB, "CLOB" );

    registerFunction( "year", new SQLFunctionTemplate( Hibernate.INTEGER, "extract(year from ?1)" ) );
    registerFunction( "length", new SQLFunctionTemplate( Hibernate.INTEGER, "character_length(?1)" ) );
    registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
    registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 from ?2 for ?3)" ) );
    registerFunction( "locate", new SQLFunctionTemplate( Hibernate.STRING, "position(?1 in ?2)" ) );
    registerFunction( "mod", new SQLFunctionTemplate( Hibernate.STRING, "?1 mod ?2" ) );
    registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "cast(?1 as varchar(255))" ) );

    // bit_length feels a bit broken to me. We have to cast to char in order to
    // pass when a numeric value is supplied. But of course the answers given will
    // be wildly different for these two datatypes. 1234.5678 will be 9 bytes as
    // a char string but will be 8 or 16 bytes as a true numeric.
    // Jay Nance 2006-09-22
    registerFunction(
            "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(cast(?1 as char))*4" )
    );

    // The preference here would be
    //   SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_timestamp(?1)", false)
    // but this appears not to work.
    // Jay Nance 2006-09-22
    registerFunction( "current_timestamp", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_timestamp" ) );
    registerFunction( "current_time", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_time" ) );
    registerFunction( "current_date", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_date" ) );
    // IBID for current_time and current_date

    registerKeyword( "password" );
    registerKeyword( "type" );
    registerKeyword( "title" );
    registerKeyword( "year" );
    registerKeyword( "month" );
    registerKeyword( "summary" );
    registerKeyword( "alias" );
    registerKeyword( "value" );
    registerKeyword( "first" );
    registerKeyword( "role" );
    registerKeyword( "account" );
    registerKeyword( "class" );

    // Tell hibernate to use getBytes instead of getBinaryStream
    getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
    // No batch statements
    getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
项目:cacheonix-core    文件:Oracle8iDialect.java   
protected void registerFunctions() {
    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( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
    registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
    registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
    registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
    registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
    registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
    registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
    registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
    registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
    registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );

    registerFunction( "round", new StandardSQLFunction("round") );
    registerFunction( "trunc", new StandardSQLFunction("trunc") );
    registerFunction( "ceil", new StandardSQLFunction("ceil") );
    registerFunction( "floor", new StandardSQLFunction("floor") );

    registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
    registerFunction( "initcap", new StandardSQLFunction("initcap") );
    registerFunction( "lower", new StandardSQLFunction("lower") );
    registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
    registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
    registerFunction( "soundex", new StandardSQLFunction("soundex") );
    registerFunction( "upper", new StandardSQLFunction("upper") );
    registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
    registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );

    registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
    registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.TIMESTAMP) );

    registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
    registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
    registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );

    registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
    registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
    registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
    registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
    registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );

    registerFunction( "rowid", new NoArgSQLFunction("rowid", Hibernate.LONG, false) );
    registerFunction( "rownum", new NoArgSQLFunction("rownum", Hibernate.LONG, false) );

    // Multi-param string dialect functions...
    registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
    registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.INTEGER) );
    registerFunction( "instrb", new StandardSQLFunction("instrb", Hibernate.INTEGER) );
    registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
    registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
    registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
    registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
    registerFunction( "substrb", new StandardSQLFunction("substrb", Hibernate.STRING) );
    registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );

    registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
    registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "instr(?2,?1)" ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "vsize(?1)*8" ) );
    registerFunction( "coalesce", new NvlFunction() );

    // Multi-param numeric dialect functions...
    registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.FLOAT) );
    registerFunction( "log", new StandardSQLFunction("log", Hibernate.INTEGER) );
    registerFunction( "mod", new StandardSQLFunction("mod", Hibernate.INTEGER) );
    registerFunction( "nvl", new StandardSQLFunction("nvl") );
    registerFunction( "nvl2", new StandardSQLFunction("nvl2") );
    registerFunction( "power", new StandardSQLFunction("power", Hibernate.FLOAT) );

    // Multi-param date dialect functions...
    registerFunction( "add_months", new StandardSQLFunction("add_months", Hibernate.DATE) );
    registerFunction( "months_between", new StandardSQLFunction("months_between", Hibernate.FLOAT) );
    registerFunction( "next_day", new StandardSQLFunction("next_day", Hibernate.DATE) );

    registerFunction( "str", new StandardSQLFunction("to_char", Hibernate.STRING) );
}
项目:cacheonix-core    文件:SybaseDialect.java   
public SybaseDialect() {
    super();
    registerColumnType( Types.BIT, "tinyint" ); //Sybase BIT type does not support null values
    registerColumnType( Types.BIGINT, "numeric(19,0)" );
    registerColumnType( Types.SMALLINT, "smallint" );
    registerColumnType( Types.TINYINT, "tinyint" );
    registerColumnType( Types.INTEGER, "int" );
    registerColumnType( Types.CHAR, "char(1)" );
    registerColumnType( Types.VARCHAR, "varchar($l)" );
    registerColumnType( Types.FLOAT, "float" );
    registerColumnType( Types.DOUBLE, "double precision" );
    registerColumnType( Types.DATE, "datetime" );
    registerColumnType( Types.TIME, "datetime" );
    registerColumnType( Types.TIMESTAMP, "datetime" );
    registerColumnType( Types.VARBINARY, "varbinary($l)" );
    registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
    registerColumnType( Types.BLOB, "image" );
    registerColumnType( Types.CLOB, "text" );

    registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
    registerFunction( "char", new StandardSQLFunction("char", Hibernate.CHARACTER) );
    registerFunction( "len", new StandardSQLFunction("len", Hibernate.LONG) );
    registerFunction( "lower", new StandardSQLFunction("lower") );
    registerFunction( "upper", new StandardSQLFunction("upper") );
    registerFunction( "str", new StandardSQLFunction("str", Hibernate.STRING) );
    registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
    registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
    registerFunction( "reverse", new StandardSQLFunction("reverse") );
    registerFunction( "space", new StandardSQLFunction("space", Hibernate.STRING) );

    registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING) );

    registerFunction( "current_timestamp", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP) );
    registerFunction( "current_time", new NoArgSQLFunction("getdate", Hibernate.TIME) );
    registerFunction( "current_date", new NoArgSQLFunction("getdate", Hibernate.DATE) );

    registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP) );
    registerFunction( "getutcdate", new NoArgSQLFunction("getutcdate", Hibernate.TIMESTAMP) );
    registerFunction( "day", new StandardSQLFunction("day", Hibernate.INTEGER) );
    registerFunction( "month", new StandardSQLFunction("month", Hibernate.INTEGER) );
    registerFunction( "year", new StandardSQLFunction("year", Hibernate.INTEGER) );
    registerFunction( "datename", new StandardSQLFunction("datename", 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( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
    registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE) );
    registerFunction( "log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
    registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
    registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
    registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
    registerFunction( "pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
    registerFunction( "square", new StandardSQLFunction("square") );
    registerFunction( "rand", new StandardSQLFunction("rand", Hibernate.FLOAT) );

    registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
    registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );

    registerFunction( "round", new StandardSQLFunction("round") );
    registerFunction( "ceiling", new StandardSQLFunction("ceiling") );
    registerFunction( "floor", new StandardSQLFunction("floor") );

    registerFunction( "isnull", new StandardSQLFunction("isnull") );

    registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","+",")" ) );

    registerFunction( "length", new StandardSQLFunction( "len", Hibernate.INTEGER ) );
    registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "ltrim(rtrim(?1))") );
    registerFunction( "locate", new CharIndexFunction() );

    getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
}
项目:cacheonix-core    文件:Dialect.java   
protected Dialect() {
    log.info( "Using dialect: " + this );
    sqlFunctions.putAll( STANDARD_AGGREGATE_FUNCTIONS );

    // standard sql92 functions (can be overridden by subclasses)
    registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1, ?2, ?3)" ) );
    registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "locate(?1, ?2, ?3)" ) );
    registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "trim(?1 ?2 ?3 ?4)" ) );
    registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
    registerFunction( "bit_length", new StandardSQLFunction( "bit_length", Hibernate.INTEGER ) );
    registerFunction( "coalesce", new StandardSQLFunction( "coalesce" ) );
    registerFunction( "nullif", new StandardSQLFunction( "nullif" ) );
    registerFunction( "abs", new StandardSQLFunction( "abs" ) );
    registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER) );
    registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE) );
    registerFunction( "upper", new StandardSQLFunction("upper") );
    registerFunction( "lower", new StandardSQLFunction("lower") );
    registerFunction( "cast", new CastFunction() );
    registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(?1 ?2 ?3)") );

    //map second/minute/hour/day/month/year to ANSI extract(), override on subclasses
    registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(second from ?1)") );
    registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(minute from ?1)") );
    registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(hour from ?1)") );
    registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(day from ?1)") );
    registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(month from ?1)") );
    registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(year from ?1)") );

    registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as char)") );

       // register hibernate types for default use in scalar sqlquery type auto detection
    registerHibernateType( Types.BIGINT, Hibernate.BIG_INTEGER.getName() );
    registerHibernateType( Types.BINARY, Hibernate.BINARY.getName() );
    registerHibernateType( Types.BIT, Hibernate.BOOLEAN.getName() );
    registerHibernateType( Types.CHAR, Hibernate.CHARACTER.getName() );
    registerHibernateType( Types.DATE, Hibernate.DATE.getName() );
    registerHibernateType( Types.DOUBLE, Hibernate.DOUBLE.getName() );
    registerHibernateType( Types.FLOAT, Hibernate.FLOAT.getName() );
    registerHibernateType( Types.INTEGER, Hibernate.INTEGER.getName() );
    registerHibernateType( Types.SMALLINT, Hibernate.SHORT.getName() );
    registerHibernateType( Types.TINYINT, Hibernate.BYTE.getName() );
    registerHibernateType( Types.TIME, Hibernate.TIME.getName() );
    registerHibernateType( Types.TIMESTAMP, Hibernate.TIMESTAMP.getName() );
    registerHibernateType( Types.VARCHAR, Hibernate.STRING.getName() );
    registerHibernateType( Types.VARBINARY, Hibernate.BINARY.getName() );
    registerHibernateType( Types.NUMERIC, Hibernate.BIG_DECIMAL.getName() );
    registerHibernateType( Types.DECIMAL, Hibernate.BIG_DECIMAL.getName() );
    registerHibernateType( Types.BLOB, Hibernate.BLOB.getName() );
    registerHibernateType( Types.CLOB, Hibernate.CLOB.getName() );
    registerHibernateType( Types.REAL, Hibernate.FLOAT.getName() );
}
项目:high-performance-java-persistence    文件:OracleStoredProcedureTest.java   
@Override
protected void registerFunctions() {
    super.registerFunctions();
    registerFunction( "fn_count_comments", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "fn_count_comments(?1)" ) );
}
项目:budgetapp    文件:CustomPostgreSQLDialect.java   
public CustomPostgreSQLDialect() {
    super();
    registerFunction("dayofweek", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(dow from ?1)") );
    registerFunction( "week", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(week from ?1)") );
}
项目:budgetapp    文件:CustomHSQLDialect.java   
public CustomHSQLDialect() {
    super();
    registerFunction( "week", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(week_of_year from ?1)") );
}
项目:yeti    文件:SQLiteDialect.java   
public SQLiteDialect() {
    registerColumnType(Types.BIT, "boolean");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric($p, $s)");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "datetime");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "boolean");

    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2"));
    registerFunction("quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING));
    registerFunction("random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER));
    registerFunction("round", new StandardSQLFunction("round"));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("trim", new AbstractAnsiTrimEmulationFunction() {
        @Override
        protected SQLFunction resolveBothSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
        }

        @Override
        protected SQLFunction resolveBothSpaceTrimFromFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)");
        }

        @Override
        protected SQLFunction resolveLeadingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)");
        }

        @Override
        protected SQLFunction resolveTrailingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)");
        }

        @Override
        protected SQLFunction resolveBothTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)");
        }

        @Override
        protected SQLFunction resolveLeadingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)");
        }

        @Override
        protected SQLFunction resolveTrailingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
        }
    });
}
项目:JMaNGOS    文件:MySQLDialect.java   
public MySQLDialect() {
    super();
    registerFunction("bitwise_and", new SQLFunctionTemplate(StandardBasicTypes.INTEGER,
            "(?1 & ?2)"));
}