Package org.hibernate.dialect.function

Examples of org.hibernate.dialect.function.SQLFunctionTemplate


  protected Dialect() {
        LOG.usingDialect(this);
    StandardAnsiSqlAggregationFunctions.primeFunctionMap( sqlFunctions );

    // 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)") );
    registerFunction( "minute", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(minute from ?1)") );
    registerFunction( "hour", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(hour from ?1)") );
    registerFunction( "day", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(day from ?1)") );
    registerFunction( "month", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(month from ?1)") );
    registerFunction( "year", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "extract(year from ?1)") );

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

    registerColumnType( Types.BIT, "bit" );
    registerColumnType( Types.BOOLEAN, "boolean" );
    registerColumnType( Types.TINYINT, "tinyint" );
    registerColumnType( Types.SMALLINT, "smallint" );
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

    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( "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( "abs", new StandardSQLFunction( "abs" ) );
    registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
    registerFunction( "bit_add", new StandardSQLFunction( "bit_add" ) );
    registerFunction( "bit_and", new StandardSQLFunction( "bit_and" ) );
    registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(hex(?1))*4" ) );
    registerFunction( "bit_not", new StandardSQLFunction( "bit_not" ) );
    registerFunction( "bit_or", new StandardSQLFunction( "bit_or" ) );
    registerFunction( "bit_xor", new StandardSQLFunction( "bit_xor" ) );
    registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.LONG ) );
    registerFunction( "charextract", new StandardSQLFunction( "charextract", Hibernate.STRING ) );
    registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "+", ")" ) );
    registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
    registerFunction( "current_user", new NoArgSQLFunction( "current_user", Hibernate.STRING, false ) );
    registerFunction( "current_time", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
    registerFunction( "current_timestamp", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
    registerFunction( "current_date", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
    registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
    registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
    registerFunction( "dba", new NoArgSQLFunction( "dba", Hibernate.STRING, true ) );
    registerFunction( "dow", new StandardSQLFunction( "dow", Hibernate.STRING ) );
    registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "date_part('?1', ?3)" ) );
    registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
    registerFunction( "gmt_timestamp", new StandardSQLFunction( "gmt_timestamp", Hibernate.STRING ) );
    registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.INTEGER ) );
    registerFunction( "hex", new StandardSQLFunction( "hex", Hibernate.STRING ) );
    registerFunction( "hour", new StandardSQLFunction( "hour", Hibernate.INTEGER ) );
    registerFunction( "initial_user", new NoArgSQLFunction( "initial_user", Hibernate.STRING, false ) );
    registerFunction( "intextract", new StandardSQLFunction( "intextract", Hibernate.INTEGER ) );
    registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
    registerFunction( "locate", new SQLFunctionTemplate( Hibernate.LONG, "locate(?1, ?2)" ) );
    registerFunction( "length", new StandardSQLFunction( "length", Hibernate.LONG ) );
    registerFunction( "ln", new StandardSQLFunction( "ln", Hibernate.DOUBLE ) );
    registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
    registerFunction( "lower", new StandardSQLFunction( "lower" ) );
    registerFunction( "lowercase", new StandardSQLFunction( "lowercase" ) );
    registerFunction( "minute", new StandardSQLFunction( "minute", Hibernate.INTEGER ) );
    registerFunction( "month", new StandardSQLFunction( "month", Hibernate.INTEGER ) );
    registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.LONG ) );
    registerFunction( "pad", new StandardSQLFunction( "pad", Hibernate.STRING ) );
    registerFunction( "position", new StandardSQLFunction( "position", Hibernate.LONG ) );
    registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
    registerFunction( "random", new NoArgSQLFunction( "random", Hibernate.LONG, true ) );
    registerFunction( "randomf", new NoArgSQLFunction( "randomf", Hibernate.DOUBLE, true ) );
    registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
    registerFunction( "session_user", new NoArgSQLFunction( "session_user", Hibernate.STRING, false ) );
    registerFunction( "second", new StandardSQLFunction( "second", Hibernate.INTEGER ) );
    registerFunction( "size", new NoArgSQLFunction( "size", Hibernate.LONG, true ) );
    registerFunction( "squeeze", new StandardSQLFunction( "squeeze" ) );
    registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
    registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
    registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
    registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 FROM ?2 FOR ?3)" ) );
    registerFunction( "system_user", new NoArgSQLFunction( "system_user", Hibernate.STRING, false ) );
    //registerFunction( "trim", new StandardSQLFunction( "trim", Hibernate.STRING ) );
    registerFunction( "unhex", new StandardSQLFunction( "unhex", Hibernate.STRING ) );
    registerFunction( "upper", new StandardSQLFunction( "upper" ) );
    registerFunction( "uppercase", new StandardSQLFunction( "uppercase" ) );
View Full Code Here

    registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
    registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
    registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
    registerFunction("microsecond", new StandardSQLFunction("microsecond", Hibernate.INTEGER) );

    registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "second(?1)") );
    registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "minute(?1)") );
    registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "hour(?1)") );
    registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "day(?1)") );
    registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "month(?1)") );
    registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "year(?1)") );

    registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "?1(?3)") );

    registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING) );
    registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING) );
    registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER) );
    registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
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( "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

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.