Package org.hibernate.dialect.function

Examples of org.hibernate.dialect.function.SQLFunctionTemplate


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

    registerFunction( "locate", new PositionSubstringFunction() );

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

    getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
  }
View Full Code Here


    registerFunction( "acos", new StandardJDBCEscapeFunction( "acos", Hibernate.DOUBLE ) );
    registerFunction( "%alphaup", new StandardSQLFunction( "%alphaup", Hibernate.STRING ) );
    registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.STRING ) );
    registerFunction( "asin", new StandardJDBCEscapeFunction( "asin", Hibernate.DOUBLE ) );
    registerFunction( "atan", new StandardJDBCEscapeFunction( "atan", Hibernate.DOUBLE ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "($length(?1)*8)" ) );
    // hibernate impelemnts cast in Dialect.java
    registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.INTEGER ) );
    registerFunction( "char", new StandardJDBCEscapeFunction( "char", Hibernate.CHARACTER ) );
    registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.INTEGER ) );
    registerFunction( "char_length", new StandardSQLFunction( "char_length", Hibernate.INTEGER ) );
    registerFunction( "cos", new StandardJDBCEscapeFunction( "cos", Hibernate.DOUBLE ) );
    registerFunction( "cot", new StandardJDBCEscapeFunction( "cot", Hibernate.DOUBLE ) );
    registerFunction( "coalesce", new VarArgsSQLFunction( "coalesce(", ",", ")" ) );
    registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "", "||", "" ) );
    registerFunction( "convert", new ConvertFunction() );
    registerFunction( "curdate", new StandardJDBCEscapeFunction( "curdate", Hibernate.DATE ) );
    registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE, false ) );
    registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME, false ) );
    registerFunction(
        "current_timestamp", new ConditionalParenthesisFunction( "current_timestamp", Hibernate.TIMESTAMP )
    );
    registerFunction( "curtime", new StandardJDBCEscapeFunction( "curtime", Hibernate.TIME ) );
    registerFunction( "database", new StandardJDBCEscapeFunction( "database", Hibernate.STRING ) );
    registerFunction( "dateadd", new VarArgsSQLFunction( Hibernate.TIMESTAMP, "dateadd(", ",", ")" ) );
    registerFunction( "datediff", new VarArgsSQLFunction( Hibernate.INTEGER, "datediff(", ",", ")" ) );
    registerFunction( "datename", new VarArgsSQLFunction( Hibernate.STRING, "datename(", ",", ")" ) );
    registerFunction( "datepart", new VarArgsSQLFunction( Hibernate.INTEGER, "datepart(", ",", ")" ) );
    registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
    registerFunction( "dayname", new StandardJDBCEscapeFunction( "dayname", Hibernate.STRING ) );
    registerFunction( "dayofmonth", new StandardJDBCEscapeFunction( "dayofmonth", Hibernate.INTEGER ) );
    registerFunction( "dayofweek", new StandardJDBCEscapeFunction( "dayofweek", Hibernate.INTEGER ) );
    registerFunction( "dayofyear", new StandardJDBCEscapeFunction( "dayofyear", Hibernate.INTEGER ) );
    // is it necessary to register %exact since it can only appear in a where clause?
    registerFunction( "%exact", new StandardSQLFunction( "%exact", Hibernate.STRING ) );
    registerFunction( "exp", new StandardJDBCEscapeFunction( "exp", Hibernate.DOUBLE ) );
    registerFunction( "%external", new StandardSQLFunction( "%external", Hibernate.STRING ) );
    registerFunction( "$extract", new VarArgsSQLFunction( Hibernate.INTEGER, "$extract(", ",", ")" ) );
    registerFunction( "$find", new VarArgsSQLFunction( Hibernate.INTEGER, "$find(", ",", ")" ) );
    registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.INTEGER ) );
    registerFunction( "getdate", new StandardSQLFunction( "getdate", Hibernate.TIMESTAMP ) );
    registerFunction( "hour", new StandardJDBCEscapeFunction( "hour", Hibernate.INTEGER ) );
    registerFunction( "ifnull", new VarArgsSQLFunction( "ifnull(", ",", ")" ) );
    registerFunction( "%internal", new StandardSQLFunction( "%internal" ) );
    registerFunction( "isnull", new VarArgsSQLFunction( "isnull(", ",", ")" ) );
    registerFunction( "isnumeric", new StandardSQLFunction( "isnumeric", Hibernate.INTEGER ) );
    registerFunction( "lcase", new StandardJDBCEscapeFunction( "lcase", Hibernate.STRING ) );
    registerFunction( "left", new StandardJDBCEscapeFunction( "left", Hibernate.STRING ) );
    registerFunction( "len", new StandardSQLFunction( "len", Hibernate.INTEGER ) );
    registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
    registerFunction( "$length", new VarArgsSQLFunction( "$length(", ",", ")" ) );
    // aggregate functions shouldn't be registered, right?
    //registerFunction( "list", new StandardSQLFunction("list",Hibernate.STRING) );
    // stopped on $list
    registerFunction( "$list", new VarArgsSQLFunction( "$list(", ",", ")" ) );
    registerFunction( "$listdata", new VarArgsSQLFunction( "$listdata(", ",", ")" ) );
    registerFunction( "$listfind", new VarArgsSQLFunction( "$listfind(", ",", ")" ) );
    registerFunction( "$listget", new VarArgsSQLFunction( "$listget(", ",", ")" ) );
    registerFunction( "$listlength", new StandardSQLFunction( "$listlength", Hibernate.INTEGER ) );
    registerFunction( "locate", new StandardSQLFunction( "$FIND", Hibernate.INTEGER ) );
    registerFunction( "log", new StandardJDBCEscapeFunction( "log", Hibernate.DOUBLE ) );
    registerFunction( "log10", new StandardJDBCEscapeFunction( "log", Hibernate.DOUBLE ) );
    registerFunction( "lower", new StandardSQLFunction( "lower" ) );
    registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
    registerFunction( "minute", new StandardJDBCEscapeFunction( "minute", Hibernate.INTEGER ) );
    registerFunction( "mod", new StandardJDBCEscapeFunction( "mod", Hibernate.DOUBLE ) );
    registerFunction( "month", new StandardJDBCEscapeFunction( "month", Hibernate.INTEGER ) );
    registerFunction( "monthname", new StandardJDBCEscapeFunction( "monthname", Hibernate.STRING ) );
    registerFunction( "now", new StandardJDBCEscapeFunction( "monthname", Hibernate.TIMESTAMP ) );
    registerFunction( "nullif", new VarArgsSQLFunction( "nullif(", ",", ")" ) );
    registerFunction( "nvl", new NvlFunction() );
    registerFunction( "%odbcin", new StandardSQLFunction( "%odbcin" ) );
    registerFunction( "%odbcout", new StandardSQLFunction( "%odbcin" ) );
    registerFunction( "%pattern", new VarArgsSQLFunction( Hibernate.STRING, "", "%pattern", "" ) );
    registerFunction( "pi", new StandardJDBCEscapeFunction( "pi", Hibernate.DOUBLE ) );
    registerFunction( "$piece", new VarArgsSQLFunction( Hibernate.STRING, "$piece(", ",", ")" ) );
    registerFunction( "position", new VarArgsSQLFunction( Hibernate.INTEGER, "position(", " in ", ")" ) );
    registerFunction( "power", new VarArgsSQLFunction( Hibernate.STRING, "power(", ",", ")" ) );
    registerFunction( "quarter", new StandardJDBCEscapeFunction( "quarter", Hibernate.INTEGER ) );
    registerFunction( "repeat", new VarArgsSQLFunction( Hibernate.STRING, "repeat(", ",", ")" ) );
    registerFunction( "replicate", new VarArgsSQLFunction( Hibernate.STRING, "replicate(", ",", ")" ) );
    registerFunction( "right", new StandardJDBCEscapeFunction( "right", Hibernate.STRING ) );
    registerFunction( "round", new VarArgsSQLFunction( Hibernate.FLOAT, "round(", ",", ")" ) );
    registerFunction( "rtrim", new StandardSQLFunction( "rtrim", Hibernate.STRING ) );
    registerFunction( "second", new StandardJDBCEscapeFunction( "second", Hibernate.INTEGER ) );
    registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
    registerFunction( "sin", new StandardJDBCEscapeFunction( "sin", Hibernate.DOUBLE ) );
    registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
    registerFunction( "%sqlstring", new VarArgsSQLFunction( Hibernate.STRING, "%sqlstring(", ",", ")" ) );
    registerFunction( "%sqlupper", new VarArgsSQLFunction( Hibernate.STRING, "%sqlupper(", ",", ")" ) );
    registerFunction( "sqrt", new StandardJDBCEscapeFunction( "SQRT", Hibernate.DOUBLE ) );
    registerFunction( "%startswith", new VarArgsSQLFunction( Hibernate.STRING, "", "%startswith", "" ) );
    // below is for Cache' that don't have str in 2007.1 there is str and we register str directly
    registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "cast(?1 as char varying)" ) );
    registerFunction( "string", new VarArgsSQLFunction( Hibernate.STRING, "string(", ",", ")" ) );
    // note that %string is deprecated
    registerFunction( "%string", new VarArgsSQLFunction( Hibernate.STRING, "%string(", ",", ")" ) );
    registerFunction( "substr", new VarArgsSQLFunction( Hibernate.STRING, "substr(", ",", ")" ) );
    registerFunction( "substring", new VarArgsSQLFunction( Hibernate.STRING, "substring(", ",", ")" ) );
View Full Code Here

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

    registerFunction("rtrim", new StandardSQLFunction("rtrim") );
    registerFunction( "substr", new StandardSQLFunction( "substr", Hibernate.STRING ) );
    registerFunction( "posstr", new StandardSQLFunction( "posstr", Hibernate.INTEGER ) );

    registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "length(?1)*8" ) );
    registerFunction( "trim", new AnsiTrimEmulationFunction() );

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

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

    registerKeyword("current");
    registerKeyword("date");
    registerKeyword("time");
    registerKeyword("timestamp");
View Full Code Here

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

    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

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

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

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

    registerFunction("rtrim", new StandardSQLFunction("rtrim") );
    registerFunction( "substr", new StandardSQLFunction( "substr", Hibernate.STRING ) );
    registerFunction( "posstr", new StandardSQLFunction( "posstr", Hibernate.INTEGER ) );

    registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "length(?1)*8" ) );
    registerFunction( "trim", new AnsiTrimEmulationFunction() );

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

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

    registerKeyword("current");
    registerKeyword("date");
    registerKeyword("time");
    registerKeyword("timestamp");
View Full Code Here

TOP

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

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.