Package org.hibernate.dialect.function

Examples of org.hibernate.dialect.function.StandardSQLFunction


    registerColumnType( Types.BINARY, "BLOB($1)" );
    registerColumnType( Types.NUMERIC, "NUMERIC(19, $l)" );
    registerColumnType( Types.BLOB, "BLOB($l)" );
    registerColumnType( Types.CLOB, "NCLOB($l)" );

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

    registerFunction( "dacos", new StandardSQLFunction( "dacos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "acos", new StandardSQLFunction( "dacos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dasin", new StandardSQLFunction( "dasin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "asin", new StandardSQLFunction( "dasin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "datan", new StandardSQLFunction( "datan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "atan", new StandardSQLFunction( "datan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "datan2", new StandardSQLFunction( "datan2", StandardBasicTypes.DOUBLE ) );
    registerFunction( "atan2", new StandardSQLFunction( "datan2", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dcos", new StandardSQLFunction( "dcos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "cos", new StandardSQLFunction( "dcos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dcot", new StandardSQLFunction( "dcot", StandardBasicTypes.DOUBLE ) );
    registerFunction( "cot", new StandardSQLFunction( "dcot", StandardBasicTypes.DOUBLE ) );
    registerFunction( "ddegrees", new StandardSQLFunction( "ddegrees", StandardBasicTypes.DOUBLE ) );
    registerFunction( "degrees", new StandardSQLFunction( "ddegrees", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dexp", new StandardSQLFunction( "dexp", StandardBasicTypes.DOUBLE ) );
    registerFunction( "exp", new StandardSQLFunction( "dexp", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dlog", new StandardSQLFunction( "dlog", StandardBasicTypes.DOUBLE ) );
    registerFunction( "log", new StandardSQLFunction( "dlog", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dlog10", new StandardSQLFunction( "dlog10", StandardBasicTypes.DOUBLE ) );
    registerFunction( "log10", new StandardSQLFunction( "dlog10", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dradian", new StandardSQLFunction( "dradian", StandardBasicTypes.DOUBLE ) );
    registerFunction( "radian", new StandardSQLFunction( "dradian", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dsin", new StandardSQLFunction( "dsin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "sin", new StandardSQLFunction( "dsin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "soundex", new StandardSQLFunction( "soundex", StandardBasicTypes.STRING ) );
    registerFunction( "dsqrt", new StandardSQLFunction( "dsqrt", StandardBasicTypes.DOUBLE ) );
    registerFunction( "sqrt", new StandardSQLFunction( "dsqrt", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dtan", new StandardSQLFunction( "dtan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "tan", new StandardSQLFunction( "dtan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "dpower", new StandardSQLFunction( "dpower" ) );
    registerFunction( "power", new StandardSQLFunction( "dpower" ) );

    registerFunction( "date", new StandardSQLFunction( "date", StandardBasicTypes.DATE ) );
    registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", StandardBasicTypes.INTEGER ) );
    registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", StandardBasicTypes.INTEGER ) );
    registerFunction( "time", new StandardSQLFunction( "time", StandardBasicTypes.TIME ) );
    registerFunction( "timestamp", new StandardSQLFunction( "timestamp", StandardBasicTypes.TIMESTAMP ) );
    registerFunction( "week", new StandardSQLFunction( "week", StandardBasicTypes.INTEGER ) );


    registerFunction( "varchar", new StandardSQLFunction( "varchar", StandardBasicTypes.STRING ) );
    registerFunction( "real", new StandardSQLFunction( "real", StandardBasicTypes.FLOAT ) );
    registerFunction( "bigint", new StandardSQLFunction( "bigint", StandardBasicTypes.LONG ) );
    registerFunction( "char", new StandardSQLFunction( "char", StandardBasicTypes.CHARACTER ) );
    registerFunction( "integer", new StandardSQLFunction( "integer", StandardBasicTypes.INTEGER ) );
    registerFunction( "smallint", new StandardSQLFunction( "smallint", StandardBasicTypes.SHORT ) );

    registerFunction( "ascii_char", new StandardSQLFunction( "ascii_char", StandardBasicTypes.CHARACTER ) );
    registerFunction( "ascii_code", new StandardSQLFunction( "ascii_code", StandardBasicTypes.STRING ) );
    registerFunction( "unicode_char", new StandardSQLFunction( "unicode_char", StandardBasicTypes.LONG ) );
    registerFunction( "unicode_code", new StandardSQLFunction( "unicode_code", StandardBasicTypes.STRING ) );
    registerFunction( "upper", new StandardSQLFunction( "upper" ) );
    registerFunction( "lower", new StandardSQLFunction( "lower" ) );
    registerFunction( "char_length", new StandardSQLFunction( "char_length", StandardBasicTypes.LONG ) );
    registerFunction( "bit_length", new StandardSQLFunction( "bit_length", StandardBasicTypes.STRING ) );

    getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
    getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, "50" );
  }
View Full Code Here


    // where section like 'Function%' order by section, topic
    //
    // see also ->  http://www.h2database.com/html/functions.html

    // Numeric Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "acos", new StandardSQLFunction( "acos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "asin", new StandardSQLFunction( "asin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "atan", new StandardSQLFunction( "atan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "atan2", new StandardSQLFunction( "atan2", StandardBasicTypes.DOUBLE ) );
    registerFunction( "bitand", new StandardSQLFunction( "bitand", StandardBasicTypes.INTEGER ) );
    registerFunction( "bitor", new StandardSQLFunction( "bitor", StandardBasicTypes.INTEGER ) );
    registerFunction( "bitxor", new StandardSQLFunction( "bitxor", StandardBasicTypes.INTEGER ) );
    registerFunction( "ceiling", new StandardSQLFunction( "ceiling", StandardBasicTypes.DOUBLE ) );
    registerFunction( "cos", new StandardSQLFunction( "cos", StandardBasicTypes.DOUBLE ) );
    registerFunction( "compress", new StandardSQLFunction( "compress", StandardBasicTypes.BINARY ) );
    registerFunction( "cot", new StandardSQLFunction( "cot", StandardBasicTypes.DOUBLE ) );
    registerFunction( "decrypt", new StandardSQLFunction( "decrypt", StandardBasicTypes.BINARY ) );
    registerFunction( "degrees", new StandardSQLFunction( "degrees", StandardBasicTypes.DOUBLE ) );
    registerFunction( "encrypt", new StandardSQLFunction( "encrypt", StandardBasicTypes.BINARY ) );
    registerFunction( "exp", new StandardSQLFunction( "exp", StandardBasicTypes.DOUBLE ) );
    registerFunction( "expand", new StandardSQLFunction( "compress", StandardBasicTypes.BINARY ) );
    registerFunction( "floor", new StandardSQLFunction( "floor", StandardBasicTypes.DOUBLE ) );
    registerFunction( "hash", new StandardSQLFunction( "hash", StandardBasicTypes.BINARY ) );
    registerFunction( "log", new StandardSQLFunction( "log", StandardBasicTypes.DOUBLE ) );
    registerFunction( "log10", new StandardSQLFunction( "log10", StandardBasicTypes.DOUBLE ) );
    registerFunction( "pi", new NoArgSQLFunction( "pi", StandardBasicTypes.DOUBLE ) );
    registerFunction( "power", new StandardSQLFunction( "power", StandardBasicTypes.DOUBLE ) );
    registerFunction( "radians", new StandardSQLFunction( "radians", StandardBasicTypes.DOUBLE ) );
    registerFunction( "rand", new NoArgSQLFunction( "rand", StandardBasicTypes.DOUBLE ) );
    registerFunction( "round", new StandardSQLFunction( "round", StandardBasicTypes.DOUBLE ) );
    registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", StandardBasicTypes.DOUBLE ) );
    registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) );
    registerFunction( "sin", new StandardSQLFunction( "sin", StandardBasicTypes.DOUBLE ) );
    registerFunction( "tan", new StandardSQLFunction( "tan", StandardBasicTypes.DOUBLE ) );
    registerFunction( "truncate", new StandardSQLFunction( "truncate", StandardBasicTypes.DOUBLE ) );

    // String Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "ascii", new StandardSQLFunction( "ascii", StandardBasicTypes.INTEGER ) );
    registerFunction( "char", new StandardSQLFunction( "char", StandardBasicTypes.CHARACTER ) );
    registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
    registerFunction( "difference", new StandardSQLFunction( "difference", StandardBasicTypes.INTEGER ) );
    registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", StandardBasicTypes.STRING ) );
    registerFunction( "insert", new StandardSQLFunction( "lower", StandardBasicTypes.STRING ) );
    registerFunction( "left", new StandardSQLFunction( "left", StandardBasicTypes.STRING ) );
    registerFunction( "lcase", new StandardSQLFunction( "lcase", StandardBasicTypes.STRING ) );
    registerFunction( "ltrim", new StandardSQLFunction( "ltrim", StandardBasicTypes.STRING ) );
    registerFunction( "octet_length", new StandardSQLFunction( "octet_length", StandardBasicTypes.INTEGER ) );
    registerFunction( "position", new StandardSQLFunction( "position", StandardBasicTypes.INTEGER ) );
    registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex", StandardBasicTypes.STRING ) );
    registerFunction( "repeat", new StandardSQLFunction( "repeat", StandardBasicTypes.STRING ) );
    registerFunction( "replace", new StandardSQLFunction( "replace", StandardBasicTypes.STRING ) );
    registerFunction( "right", new StandardSQLFunction( "right", StandardBasicTypes.STRING ) );
    registerFunction( "rtrim", new StandardSQLFunction( "rtrim", StandardBasicTypes.STRING ) );
    registerFunction( "soundex", new StandardSQLFunction( "soundex", StandardBasicTypes.STRING ) );
    registerFunction( "space", new StandardSQLFunction( "space", StandardBasicTypes.STRING ) );
    registerFunction( "stringencode", new StandardSQLFunction( "stringencode", StandardBasicTypes.STRING ) );
    registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", StandardBasicTypes.STRING ) );
    registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", StandardBasicTypes.BINARY ) );
    registerFunction( "ucase", new StandardSQLFunction( "ucase", StandardBasicTypes.STRING ) );
    registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", StandardBasicTypes.STRING ) );

    // Time and Date Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "curdate", new NoArgSQLFunction( "curdate", StandardBasicTypes.DATE ) );
    registerFunction( "curtime", new NoArgSQLFunction( "curtime", StandardBasicTypes.TIME ) );
    registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", StandardBasicTypes.TIME ) );
    registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE ) );
    registerFunction( "current_time", new NoArgSQLFunction( "current_time", StandardBasicTypes.TIME ) );
    registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", StandardBasicTypes.TIMESTAMP ) );
    registerFunction( "datediff", new StandardSQLFunction( "datediff", StandardBasicTypes.INTEGER ) );
    registerFunction( "dayname", new StandardSQLFunction( "dayname", StandardBasicTypes.STRING ) );
    registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", StandardBasicTypes.INTEGER ) );
    registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", StandardBasicTypes.INTEGER ) );
    registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", StandardBasicTypes.INTEGER ) );
    registerFunction( "monthname", new StandardSQLFunction( "monthname", StandardBasicTypes.STRING ) );
    registerFunction( "now", new NoArgSQLFunction( "now", StandardBasicTypes.TIMESTAMP ) );
    registerFunction( "quarter", new StandardSQLFunction( "quarter", StandardBasicTypes.INTEGER ) );
    registerFunction( "week", new StandardSQLFunction( "week", StandardBasicTypes.INTEGER ) );

    // System Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "database", new NoArgSQLFunction( "database", StandardBasicTypes.STRING ) );
    registerFunction( "user", new NoArgSQLFunction( "user", StandardBasicTypes.STRING ) );
View Full Code Here

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

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

  protected void registerReverseHibernateTypeMappings() {
  }

  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( "last_day", new StandardSQLFunction("last_day", 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) );
  }
View Full Code Here

    // 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)") );
View Full Code Here

    // where section like 'Function%' order by section, topic
    //
    // see also ->  http://www.h2database.com/html/functions.html

    // Numeric Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
    registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
    registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
    registerFunction( "atan2", new StandardSQLFunction( "atan2", Hibernate.DOUBLE ) );
    registerFunction( "bitand", new StandardSQLFunction( "bitand", Hibernate.INTEGER ) );
    registerFunction( "bitor", new StandardSQLFunction( "bitor", Hibernate.INTEGER ) );
    registerFunction( "bitxor", new StandardSQLFunction( "bitxor", Hibernate.INTEGER ) );
    registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.DOUBLE ) );
    registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
    registerFunction( "compress", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
    registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
    registerFunction( "decrypt", new StandardSQLFunction( "decrypt", Hibernate.BINARY ) );
    registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
    registerFunction( "encrypt", new StandardSQLFunction( "encrypt", Hibernate.BINARY ) );
    registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
    registerFunction( "expand", new StandardSQLFunction( "compress", Hibernate.BINARY ) );
    registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.DOUBLE ) );
    registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.BINARY ) );
    registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
    registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
    registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
    registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
    registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
    registerFunction( "rand", new NoArgSQLFunction( "rand", Hibernate.DOUBLE ) );
    registerFunction( "round", new StandardSQLFunction( "round", Hibernate.DOUBLE ) );
    registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic", Hibernate.DOUBLE ) );
    registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
    registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
    registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
    registerFunction( "truncate", new StandardSQLFunction( "truncate", Hibernate.DOUBLE ) );

    // String Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
    registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
    registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
    registerFunction( "difference", new StandardSQLFunction( "difference", Hibernate.INTEGER ) );
    registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw", Hibernate.STRING ) );
    registerFunction( "insert", new StandardSQLFunction( "lower", Hibernate.STRING ) );
    registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
    registerFunction( "lcase", new StandardSQLFunction( "lcase", Hibernate.STRING ) );
    registerFunction( "ltrim", new StandardSQLFunction( "ltrim", Hibernate.STRING ) );
    registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.INTEGER ) );
    registerFunction( "position", new StandardSQLFunction( "position", Hibernate.INTEGER ) );
    registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex", Hibernate.STRING ) );
    registerFunction( "repeat", new StandardSQLFunction( "repeat", Hibernate.STRING ) );
    registerFunction( "replace", new StandardSQLFunction( "replace", Hibernate.STRING ) );
    registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
    registerFunction( "rtrim", new StandardSQLFunction( "rtrim", Hibernate.STRING ) );
    registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
    registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
    registerFunction( "stringencode", new StandardSQLFunction( "stringencode", Hibernate.STRING ) );
    registerFunction( "stringdecode", new StandardSQLFunction( "stringdecode", Hibernate.STRING ) );
    registerFunction( "stringtoutf8", new StandardSQLFunction( "stringtoutf8", Hibernate.BINARY ) );
    registerFunction( "ucase", new StandardSQLFunction( "ucase", Hibernate.STRING ) );
    registerFunction( "utf8tostring", new StandardSQLFunction( "utf8tostring", Hibernate.STRING ) );

    // Time and Date Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
    registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
    registerFunction( "curtimestamp", new NoArgSQLFunction( "curtimestamp", Hibernate.TIME ) );
    registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE ) );
    registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME ) );
    registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP ) );
    registerFunction( "datediff", new StandardSQLFunction( "datediff", Hibernate.INTEGER ) );
    registerFunction( "dayname", new StandardSQLFunction( "dayname", Hibernate.STRING ) );
    registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
    registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
    registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
    registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
    registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
    registerFunction( "quarter", new StandardSQLFunction( "quarter", Hibernate.INTEGER ) );
    registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );

    // System Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
    registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
View Full Code Here

         * characteristics. If StandardSQLFunction(...) is used, the RDMS BIF
         * name and the return type (if any) is specified.  If
         * SQLFunctionTemplate(...) is used, the return type and a template
         * string is provided, plus an optional hasParenthesesIfNoArgs flag.
         */
    registerFunction( "abs", new StandardSQLFunction("abs") );
    registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );

    registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
    registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.INTEGER) );
    registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.INTEGER) );
    registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER) );

    // The RDMS concat() function only supports 2 parameters
    registerFunction( "concat", new SQLFunctionTemplate(Hibernate.STRING, "concat(?1, ?2)") );
    registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.STRING) );
    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("lcase", new StandardSQLFunction("lcase") );
    registerFunction("lower", new StandardSQLFunction("lower") );
    registerFunction("ltrim", new StandardSQLFunction("ltrim") );
    registerFunction("reverse", new StandardSQLFunction("reverse") );
    registerFunction("rtrim", new StandardSQLFunction("rtrim") );

    // RDMS does not directly support the trim() function, we use rtrim() and ltrim()
    registerFunction("trim", new SQLFunctionTemplate(Hibernate.INTEGER, "ltrim(rtrim(?1))" ) );
    registerFunction("soundex", new StandardSQLFunction("soundex") );
    registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) );
    registerFunction("ucase", new StandardSQLFunction("ucase") );
    registerFunction("upper", new StandardSQLFunction("upper") );

    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("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
    registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
    registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
    registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
    registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
    registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
    registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) );
    registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
    registerFunction("sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
    registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
    registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
    registerFunction("tanh", new StandardSQLFunction("tanh", 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( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );

    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("curdate", new NoArgSQLFunction("curdate",Hibernate.DATE) );
    registerFunction("curtime", new NoArgSQLFunction("curtime",Hibernate.TIME) );
    registerFunction("days", new StandardSQLFunction("days",Hibernate.INTEGER) );
    registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth",Hibernate.INTEGER) );
    registerFunction("dayname", new StandardSQLFunction("dayname",Hibernate.STRING) );
    registerFunction("dayofweek", new StandardSQLFunction("dayofweek",Hibernate.INTEGER) );
    registerFunction("dayofyear", new StandardSQLFunction("dayofyear",Hibernate.INTEGER) );
    registerFunction("hour", new StandardSQLFunction("hour",Hibernate.INTEGER) );
    registerFunction("last_day", new StandardSQLFunction("last_day",Hibernate.DATE) );
    registerFunction("microsecond", new StandardSQLFunction("microsecond",Hibernate.INTEGER) );
    registerFunction("minute", new StandardSQLFunction("minute",Hibernate.INTEGER) );
    registerFunction("month", new StandardSQLFunction("month",Hibernate.INTEGER) );
    registerFunction("monthname", new StandardSQLFunction("monthname",Hibernate.STRING) );
    registerFunction("now", new NoArgSQLFunction("now",Hibernate.TIMESTAMP) );
    registerFunction("quarter", new StandardSQLFunction("quarter",Hibernate.INTEGER) );
    registerFunction("second", new StandardSQLFunction("second",Hibernate.INTEGER) );
    registerFunction("time", new StandardSQLFunction("time",Hibernate.TIME) );
    registerFunction("timestamp", new StandardSQLFunction("timestamp",Hibernate.TIMESTAMP) );
    registerFunction("week", new StandardSQLFunction("week",Hibernate.INTEGER) );
    registerFunction("year", new StandardSQLFunction("year",Hibernate.INTEGER) );

    registerFunction("atan2", new StandardSQLFunction("atan2",Hibernate.DOUBLE) );
    registerFunction( "mod", new StandardSQLFunction("mod",Hibernate.INTEGER) );
    registerFunction( "nvl", new StandardSQLFunction("nvl") );
    registerFunction( "power", new StandardSQLFunction("power", Hibernate.DOUBLE) );

    /**
     * For a list of column types to register, see section A-1
     * in 7862 7395, the Unisys JDBC manual.
     *
 
View Full Code Here

    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" ) );

View Full Code Here

        registerColumnType( Types.BLOB, "VARBINARY(4000000)" );
        registerColumnType( Types.CLOB, "VARCHAR(4000000)" );
 
    getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
    getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
    registerFunction( "lower", new StandardSQLFunction("lower") );
    registerFunction( "upper", new StandardSQLFunction("upper") );
    registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
    registerFunction( "concat", new StandardSQLFunction("concat", Hibernate.STRING) );
    registerFunction( "mod", new StandardSQLFunction("mod") );
    registerFunction( "to_char", new StandardSQLFunction("to_char",Hibernate.STRING) );
    registerFunction( "to_date", new StandardSQLFunction("to_date",Hibernate.TIMESTAMP) );
    registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP, false) );
    registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP, false) );
    registerFunction( "nvl", new StandardSQLFunction("nvl") );

  }
View Full Code Here

    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);
  }
View Full Code Here

TOP

Related Classes of org.hibernate.dialect.function.StandardSQLFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.