Package org.hibernate.dialect.function

Examples of org.hibernate.dialect.function.SQLFunctionTemplate


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


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

    // The RDMS concat() function only supports 2 parameters
    registerFunction( "concat", new SQLFunctionTemplate( StandardBasicTypes.STRING, "concat(?1, ?2)" ) );
    registerFunction( "instr", new StandardSQLFunction( "instr", StandardBasicTypes.STRING ) );
    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( "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( StandardBasicTypes.INTEGER, "ltrim(rtrim(?1))" ) );
    registerFunction( "soundex", new StandardSQLFunction( "soundex" ) );
    registerFunction( "space", new StandardSQLFunction( "space", StandardBasicTypes.STRING ) );
    registerFunction( "ucase", new StandardSQLFunction( "ucase" ) );
    registerFunction( "upper", new StandardSQLFunction( "upper" ) );
View Full Code Here

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

    registerFunction( "soundex", new StandardSQLFunction( "soundex", 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( "str", new SQLFunctionTemplate( StandardBasicTypes.STRING, "cast(?1 as varchar(256))" ) );
    registerFunction( "to_char", new StandardSQLFunction( "to_char", StandardBasicTypes.STRING ) );
    registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex" ) );
    registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw" ) );

    // system functions
    registerFunction( "user", new NoArgSQLFunction( "user", StandardBasicTypes.STRING ) );
    registerFunction( "database", new NoArgSQLFunction( "database", StandardBasicTypes.STRING ) );

    // datetime functions
    if ( hsqldbVersion < 20 ) {
      registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", StandardBasicTypes.DATE, false ) );
    }
    else {
      registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", StandardBasicTypes.TIMESTAMP, false ) );
    }
    registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE, false ) );
    registerFunction( "curdate", new NoArgSQLFunction( "curdate", StandardBasicTypes.DATE ) );
    registerFunction(
        "current_timestamp", new NoArgSQLFunction( "current_timestamp", StandardBasicTypes.TIMESTAMP, false )
    );
    registerFunction( "now", new NoArgSQLFunction( "now", StandardBasicTypes.TIMESTAMP ) );
    registerFunction( "current_time", new NoArgSQLFunction( "current_time", StandardBasicTypes.TIME, false ) );
    registerFunction( "curtime", new NoArgSQLFunction( "curtime", StandardBasicTypes.TIME ) );
    registerFunction( "day", new StandardSQLFunction( "day", StandardBasicTypes.INTEGER ) );
    registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", StandardBasicTypes.INTEGER ) );
    registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", StandardBasicTypes.INTEGER ) );
    registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", StandardBasicTypes.INTEGER ) );
    registerFunction( "month", new StandardSQLFunction( "month", StandardBasicTypes.INTEGER ) );
    registerFunction( "year", new StandardSQLFunction( "year", StandardBasicTypes.INTEGER ) );
    registerFunction( "week", new StandardSQLFunction( "week", StandardBasicTypes.INTEGER ) );
    registerFunction( "quarter", new StandardSQLFunction( "quarter", StandardBasicTypes.INTEGER ) );
    registerFunction( "hour", new StandardSQLFunction( "hour", StandardBasicTypes.INTEGER ) );
    registerFunction( "minute", new StandardSQLFunction( "minute", StandardBasicTypes.INTEGER ) );
    registerFunction( "second", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "cast(second(?1) as int)" ) );
    registerFunction( "dayname", new StandardSQLFunction( "dayname", StandardBasicTypes.STRING ) );
    registerFunction( "monthname", new StandardSQLFunction( "monthname", StandardBasicTypes.STRING ) );

    // numeric functions
    registerFunction( "abs", new StandardSQLFunction( "abs" ) );
View Full Code Here

    registerColumnType( Types.DECIMAL, "numeric($p,$s)" );
    registerColumnType( Types.TIME, "time" );
    registerColumnType( Types.REAL, "real" );
    registerColumnType( Types.BOOLEAN, "tinyint" );

    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( "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(
            AnsiTrimEmulationFunction.LTRIM, AnsiTrimEmulationFunction.RTRIM, "str_replace"
        )
    );

    registerFunction( "atan2", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "atn2(?1, ?2" ) );
    registerFunction( "atn2", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "atn2(?1, ?2" ) );

    registerFunction( "biginttohex", new SQLFunctionTemplate( StandardBasicTypes.STRING, "biginttohext(?1)" ) );
    registerFunction( "char_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "char_length(?1)" ) );
    registerFunction( "charindex", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "charindex(?1, ?2)" ) );
    registerFunction( "coalesce", new VarArgsSQLFunction( "coalesce(", ",", ")" ) );
    registerFunction( "col_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "col_length(?1, ?2)" ) );
    registerFunction( "col_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "col_name(?1, ?2)" ) );
    // Sybase has created current_date and current_time inplace of getdate()
    registerFunction( "current_time", new NoArgSQLFunction( "current_time", StandardBasicTypes.TIME ) );
    registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE ) );


    registerFunction( "data_pages", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "data_pages(?1, ?2)" ) );
    registerFunction(
        "data_pages", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "data_pages(?1, ?2, ?3)" )
    );
    registerFunction(
        "data_pages", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "data_pages(?1, ?2, ?3, ?4)" )
    );
    registerFunction( "datalength", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datalength(?1)" ) );
    registerFunction( "dateadd", new SQLFunctionTemplate( StandardBasicTypes.TIMESTAMP, "dateadd" ) );
    registerFunction( "datediff", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datediff" ) );
    registerFunction( "datepart", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart" ) );
    registerFunction( "datetime", new SQLFunctionTemplate( StandardBasicTypes.TIMESTAMP, "datetime" ) );
    registerFunction( "db_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "db_id(?1)" ) );
    registerFunction( "difference", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "difference(?1,?2)" ) );
    registerFunction( "db_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "db_name(?1)" ) );
    registerFunction( "has_role", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "has_role(?1, ?2)" ) );
    registerFunction( "hextobigint", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "hextobigint(?1)" ) );
    registerFunction( "hextoint", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "hextoint(?1)" ) );
    registerFunction( "host_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "host_id" ) );
    registerFunction( "host_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "host_name" ) );
    registerFunction( "inttohex", new SQLFunctionTemplate( StandardBasicTypes.STRING, "inttohex(?1)" ) );
    registerFunction( "is_quiesced", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "is_quiesced(?1)" ) );
    registerFunction(
        "is_sec_service_on", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "is_sec_service_on(?1)" )
    );
    registerFunction( "object_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "object_id(?1)" ) );
    registerFunction( "object_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "object_name(?1)" ) );
    registerFunction( "pagesize", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "pagesize(?1)" ) );
    registerFunction( "pagesize", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "pagesize(?1, ?2)" ) );
    registerFunction( "pagesize", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "pagesize(?1, ?2, ?3)" ) );
    registerFunction(
        "partition_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "partition_id(?1, ?2)" )
    );
    registerFunction(
        "partition_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "partition_id(?1, ?2, ?3)" )
    );
    registerFunction(
        "partition_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "partition_name(?1, ?2)" )
    );
    registerFunction(
        "partition_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "partition_name(?1, ?2, ?3)" )
    );
    registerFunction( "patindex", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "patindex" ) );
    registerFunction( "proc_role", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "proc_role" ) );
    registerFunction( "role_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "role_name" ) );
    // check return type
    registerFunction( "row_count", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "row_count" ) );
    registerFunction( "rand2", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "rand2(?1)" ) );
    registerFunction( "rand2", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "rand2" ) );
    registerFunction( "replicate", new SQLFunctionTemplate( StandardBasicTypes.STRING, "replicate(?1,?2)" ) );
    registerFunction( "role_contain", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "role_contain" ) );
    registerFunction( "role_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "role_id" ) );
    registerFunction( "reserved_pages", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "reserved_pages" ) );
    registerFunction( "right", new SQLFunctionTemplate( StandardBasicTypes.STRING, "right" ) );
    registerFunction( "show_role", new SQLFunctionTemplate( StandardBasicTypes.STRING, "show_role" ) );
    registerFunction(
        "show_sec_services", new SQLFunctionTemplate( StandardBasicTypes.STRING, "show_sec_services" )
    );
    registerFunction( "sortkey", new VarArgsSQLFunction( StandardBasicTypes.BINARY, "sortkey(", ",", ")" ) );
    registerFunction( "soundex", new SQLFunctionTemplate( StandardBasicTypes.STRING, "sounded" ) );
    registerFunction( "stddev", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "stddev" ) );
    registerFunction( "stddev_pop", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "stddev_pop" ) );
    registerFunction( "stddev_samp", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "stddev_samp" ) );
    registerFunction( "stuff", new SQLFunctionTemplate( StandardBasicTypes.STRING, "stuff" ) );
    registerFunction( "substring", new VarArgsSQLFunction( StandardBasicTypes.STRING, "substring(", ",", ")" ) );
    registerFunction( "suser_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "suser_id" ) );
    registerFunction( "suser_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "suser_name" ) );
    registerFunction( "tempdb_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "tempdb_id" ) );
    registerFunction( "textvalid", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "textvalid" ) );
    registerFunction( "to_unichar", new SQLFunctionTemplate( StandardBasicTypes.STRING, "to_unichar(?1)" ) );
    registerFunction(
        "tran_dumptable_status",
        new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "ran_dumptable_status(?1)" )
    );
    registerFunction( "uhighsurr", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "uhighsurr" ) );
    registerFunction( "ulowsurr", new SQLFunctionTemplate( StandardBasicTypes.BOOLEAN, "ulowsurr" ) );
    registerFunction( "uscalar", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "uscalar" ) );
    registerFunction( "used_pages", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "used_pages" ) );
    registerFunction( "user_id", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "user_id" ) );
    registerFunction( "user_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "user_name" ) );
    registerFunction( "valid_name", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "valid_name" ) );
    registerFunction( "valid_user", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "valid_user" ) );
    registerFunction( "variance", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "variance" ) );
    registerFunction( "var_pop", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "var_pop" ) );
    registerFunction( "var_samp", new SQLFunctionTemplate( StandardBasicTypes.DOUBLE, "var_samp" ) );
    registerFunction( "sysdate", new NoArgSQLFunction("getdate", StandardBasicTypes.TIMESTAMP) );

    registerSybaseKeywords();
  }
View Full Code Here

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

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

  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( "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

  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

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.