Search in sources :

Example 1 with NoArgSQLFunction

use of org.hibernate.dialect.function.NoArgSQLFunction in project hibernate-orm by hibernate.

the class Cache71Dialect method commonRegistration.

protected final void commonRegistration() {
    // Note: For object <-> SQL datatype mappings see:
    //	 Configuration Manager | Advanced | SQL | System DDL Datatype Mappings
    //
    //	TBD	registerColumnType(Types.BINARY,        "binary($1)");
    // changed 08-11-2005, jsl
    registerColumnType(Types.BINARY, "varbinary($1)");
    registerColumnType(Types.BIGINT, "BigInt");
    registerColumnType(Types.BIT, "bit");
    registerColumnType(Types.CHAR, "char(1)");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.LONGVARBINARY, "longvarbinary");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.NUMERIC, "numeric($p,$s)");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.VARBINARY, "longvarbinary");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.BLOB, "longvarbinary");
    registerColumnType(Types.CLOB, "longvarchar");
    getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "false");
    getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
    getDefaultProperties().setProperty(Environment.USE_SQL_COMMENTS, "false");
    registerFunction("abs", new StandardSQLFunction("abs"));
    registerFunction("acos", new StandardJDBCEscapeFunction("acos", StandardBasicTypes.DOUBLE));
    registerFunction("%alphaup", new StandardSQLFunction("%alphaup", StandardBasicTypes.STRING));
    registerFunction("ascii", new StandardSQLFunction("ascii", StandardBasicTypes.STRING));
    registerFunction("asin", new StandardJDBCEscapeFunction("asin", StandardBasicTypes.DOUBLE));
    registerFunction("atan", new StandardJDBCEscapeFunction("atan", StandardBasicTypes.DOUBLE));
    registerFunction("bit_length", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "($length(?1)*8)"));
    registerFunction("ceiling", new StandardSQLFunction("ceiling", StandardBasicTypes.INTEGER));
    registerFunction("char", new StandardJDBCEscapeFunction("char", StandardBasicTypes.CHARACTER));
    registerFunction("character_length", new StandardSQLFunction("character_length", StandardBasicTypes.INTEGER));
    registerFunction("char_length", new StandardSQLFunction("char_length", StandardBasicTypes.INTEGER));
    registerFunction("cos", new StandardJDBCEscapeFunction("cos", StandardBasicTypes.DOUBLE));
    registerFunction("cot", new StandardJDBCEscapeFunction("cot", StandardBasicTypes.DOUBLE));
    registerFunction("coalesce", new VarArgsSQLFunction("coalesce(", ",", ")"));
    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("convert", new ConvertFunction());
    registerFunction("curdate", new StandardJDBCEscapeFunction("curdate", StandardBasicTypes.DATE));
    registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false));
    registerFunction("current_time", new NoArgSQLFunction("current_time", StandardBasicTypes.TIME, false));
    registerFunction("current_timestamp", new ConditionalParenthesisFunction("current_timestamp", StandardBasicTypes.TIMESTAMP));
    registerFunction("curtime", new StandardJDBCEscapeFunction("curtime", StandardBasicTypes.TIME));
    registerFunction("database", new StandardJDBCEscapeFunction("database", StandardBasicTypes.STRING));
    registerFunction("dateadd", new VarArgsSQLFunction(StandardBasicTypes.TIMESTAMP, "dateadd(", ",", ")"));
    registerFunction("datediff", new VarArgsSQLFunction(StandardBasicTypes.INTEGER, "datediff(", ",", ")"));
    registerFunction("datename", new VarArgsSQLFunction(StandardBasicTypes.STRING, "datename(", ",", ")"));
    registerFunction("datepart", new VarArgsSQLFunction(StandardBasicTypes.INTEGER, "datepart(", ",", ")"));
    registerFunction("day", new StandardSQLFunction("day", StandardBasicTypes.INTEGER));
    registerFunction("dayname", new StandardJDBCEscapeFunction("dayname", StandardBasicTypes.STRING));
    registerFunction("dayofmonth", new StandardJDBCEscapeFunction("dayofmonth", StandardBasicTypes.INTEGER));
    registerFunction("dayofweek", new StandardJDBCEscapeFunction("dayofweek", StandardBasicTypes.INTEGER));
    registerFunction("dayofyear", new StandardJDBCEscapeFunction("dayofyear", StandardBasicTypes.INTEGER));
    // is it necessary to register %exact since it can only appear in a where clause?
    registerFunction("%exact", new StandardSQLFunction("%exact", StandardBasicTypes.STRING));
    registerFunction("exp", new StandardJDBCEscapeFunction("exp", StandardBasicTypes.DOUBLE));
    registerFunction("%external", new StandardSQLFunction("%external", StandardBasicTypes.STRING));
    registerFunction("$extract", new VarArgsSQLFunction(StandardBasicTypes.INTEGER, "$extract(", ",", ")"));
    registerFunction("$find", new VarArgsSQLFunction(StandardBasicTypes.INTEGER, "$find(", ",", ")"));
    registerFunction("floor", new StandardSQLFunction("floor", StandardBasicTypes.INTEGER));
    registerFunction("getdate", new StandardSQLFunction("getdate", StandardBasicTypes.TIMESTAMP));
    registerFunction("hour", new StandardJDBCEscapeFunction("hour", StandardBasicTypes.INTEGER));
    registerFunction("ifnull", new VarArgsSQLFunction("ifnull(", ",", ")"));
    registerFunction("%internal", new StandardSQLFunction("%internal"));
    registerFunction("isnull", new VarArgsSQLFunction("isnull(", ",", ")"));
    registerFunction("isnumeric", new StandardSQLFunction("isnumeric", StandardBasicTypes.INTEGER));
    registerFunction("lcase", new StandardJDBCEscapeFunction("lcase", StandardBasicTypes.STRING));
    registerFunction("left", new StandardJDBCEscapeFunction("left", StandardBasicTypes.STRING));
    registerFunction("len", new StandardSQLFunction("len", StandardBasicTypes.INTEGER));
    registerFunction("$length", new VarArgsSQLFunction("$length(", ",", ")"));
    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", StandardBasicTypes.INTEGER));
    registerFunction("locate", new StandardSQLFunction("$FIND", StandardBasicTypes.INTEGER));
    registerFunction("log", new StandardJDBCEscapeFunction("log", StandardBasicTypes.DOUBLE));
    registerFunction("log10", new StandardJDBCEscapeFunction("log", StandardBasicTypes.DOUBLE));
    registerFunction("lower", new StandardSQLFunction("lower"));
    registerFunction("ltrim", new StandardSQLFunction("ltrim"));
    registerFunction("minute", new StandardJDBCEscapeFunction("minute", StandardBasicTypes.INTEGER));
    registerFunction("mod", new StandardJDBCEscapeFunction("mod", StandardBasicTypes.DOUBLE));
    registerFunction("month", new StandardJDBCEscapeFunction("month", StandardBasicTypes.INTEGER));
    registerFunction("monthname", new StandardJDBCEscapeFunction("monthname", StandardBasicTypes.STRING));
    registerFunction("now", new StandardJDBCEscapeFunction("monthname", StandardBasicTypes.TIMESTAMP));
    registerFunction("nullif", new VarArgsSQLFunction("nullif(", ",", ")"));
    registerFunction("nvl", new NvlFunction());
    registerFunction("%odbcin", new StandardSQLFunction("%odbcin"));
    registerFunction("%odbcout", new StandardSQLFunction("%odbcin"));
    registerFunction("%pattern", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "%pattern", ""));
    registerFunction("pi", new StandardJDBCEscapeFunction("pi", StandardBasicTypes.DOUBLE));
    registerFunction("$piece", new VarArgsSQLFunction(StandardBasicTypes.STRING, "$piece(", ",", ")"));
    registerFunction("position", new VarArgsSQLFunction(StandardBasicTypes.INTEGER, "position(", " in ", ")"));
    registerFunction("power", new VarArgsSQLFunction(StandardBasicTypes.STRING, "power(", ",", ")"));
    registerFunction("quarter", new StandardJDBCEscapeFunction("quarter", StandardBasicTypes.INTEGER));
    registerFunction("repeat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "repeat(", ",", ")"));
    registerFunction("replicate", new VarArgsSQLFunction(StandardBasicTypes.STRING, "replicate(", ",", ")"));
    registerFunction("right", new StandardJDBCEscapeFunction("right", StandardBasicTypes.STRING));
    registerFunction("round", new VarArgsSQLFunction(StandardBasicTypes.FLOAT, "round(", ",", ")"));
    registerFunction("rtrim", new StandardSQLFunction("rtrim", StandardBasicTypes.STRING));
    registerFunction("second", new StandardJDBCEscapeFunction("second", StandardBasicTypes.INTEGER));
    registerFunction("sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER));
    registerFunction("sin", new StandardJDBCEscapeFunction("sin", StandardBasicTypes.DOUBLE));
    registerFunction("space", new StandardSQLFunction("space", StandardBasicTypes.STRING));
    registerFunction("%sqlstring", new VarArgsSQLFunction(StandardBasicTypes.STRING, "%sqlstring(", ",", ")"));
    registerFunction("%sqlupper", new VarArgsSQLFunction(StandardBasicTypes.STRING, "%sqlupper(", ",", ")"));
    registerFunction("sqrt", new StandardJDBCEscapeFunction("SQRT", StandardBasicTypes.DOUBLE));
    registerFunction("%startswith", new VarArgsSQLFunction(StandardBasicTypes.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(StandardBasicTypes.STRING, "cast(?1 as char varying)"));
    registerFunction("string", new VarArgsSQLFunction(StandardBasicTypes.STRING, "string(", ",", ")"));
    // note that %string is deprecated
    registerFunction("%string", new VarArgsSQLFunction(StandardBasicTypes.STRING, "%string(", ",", ")"));
    registerFunction("substr", new VarArgsSQLFunction(StandardBasicTypes.STRING, "substr(", ",", ")"));
    registerFunction("substring", new VarArgsSQLFunction(StandardBasicTypes.STRING, "substring(", ",", ")"));
    registerFunction("sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.TIMESTAMP, false));
    registerFunction("tan", new StandardJDBCEscapeFunction("tan", StandardBasicTypes.DOUBLE));
    registerFunction("timestampadd", new StandardJDBCEscapeFunction("timestampadd", StandardBasicTypes.DOUBLE));
    registerFunction("timestampdiff", new StandardJDBCEscapeFunction("timestampdiff", StandardBasicTypes.DOUBLE));
    registerFunction("tochar", new VarArgsSQLFunction(StandardBasicTypes.STRING, "tochar(", ",", ")"));
    registerFunction("to_char", new VarArgsSQLFunction(StandardBasicTypes.STRING, "to_char(", ",", ")"));
    registerFunction("todate", new VarArgsSQLFunction(StandardBasicTypes.STRING, "todate(", ",", ")"));
    registerFunction("to_date", new VarArgsSQLFunction(StandardBasicTypes.STRING, "todate(", ",", ")"));
    registerFunction("tonumber", new StandardSQLFunction("tonumber"));
    registerFunction("to_number", new StandardSQLFunction("tonumber"));
    // TRIM(end_keyword string-expression-1 FROM string-expression-2)
    // use Hibernate implementation "From" is one of the parameters they pass in position ?3
    //registerFunction( "trim", new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1 ?2 from ?3)") );
    registerFunction("truncate", new StandardJDBCEscapeFunction("truncate", StandardBasicTypes.STRING));
    registerFunction("ucase", new StandardJDBCEscapeFunction("ucase", StandardBasicTypes.STRING));
    registerFunction("upper", new StandardSQLFunction("upper"));
    // %upper is deprecated
    registerFunction("%upper", new StandardSQLFunction("%upper"));
    registerFunction("user", new StandardJDBCEscapeFunction("user", StandardBasicTypes.STRING));
    registerFunction("week", new StandardJDBCEscapeFunction("user", StandardBasicTypes.INTEGER));
    registerFunction("xmlconcat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "xmlconcat(", ",", ")"));
    registerFunction("xmlelement", new VarArgsSQLFunction(StandardBasicTypes.STRING, "xmlelement(", ",", ")"));
    // xmlforest requires a new kind of function constructor
    registerFunction("year", new StandardJDBCEscapeFunction("year", StandardBasicTypes.INTEGER));
}
Also used : VarArgsSQLFunction(org.hibernate.dialect.function.VarArgsSQLFunction) StandardSQLFunction(org.hibernate.dialect.function.StandardSQLFunction) NoArgSQLFunction(org.hibernate.dialect.function.NoArgSQLFunction) SQLFunctionTemplate(org.hibernate.dialect.function.SQLFunctionTemplate) ConditionalParenthesisFunction(org.hibernate.dialect.function.ConditionalParenthesisFunction) ConvertFunction(org.hibernate.dialect.function.ConvertFunction) StandardJDBCEscapeFunction(org.hibernate.dialect.function.StandardJDBCEscapeFunction) NvlFunction(org.hibernate.dialect.function.NvlFunction)

Example 2 with NoArgSQLFunction

use of org.hibernate.dialect.function.NoArgSQLFunction in project hibernate-orm by hibernate.

the class Ingres9Dialect method registerDateTimeFunctions.

/**
	 * Register functions current_time, current_timestamp, current_date
	 */
protected void registerDateTimeFunctions() {
    registerFunction("current_time", new NoArgSQLFunction("current_time", StandardBasicTypes.TIME, false));
    registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false));
    registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false));
}
Also used : NoArgSQLFunction(org.hibernate.dialect.function.NoArgSQLFunction)

Example 3 with NoArgSQLFunction

use of org.hibernate.dialect.function.NoArgSQLFunction in project hibernate-orm by hibernate.

the class Oracle8iDialect method registerFunctions.

protected void registerFunctions() {
    registerFunction("abs", new StandardSQLFunction("abs"));
    registerFunction("sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER));
    registerFunction("acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE));
    registerFunction("asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE));
    registerFunction("atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE));
    registerFunction("bitand", new StandardSQLFunction("bitand"));
    registerFunction("cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE));
    registerFunction("cosh", new StandardSQLFunction("cosh", StandardBasicTypes.DOUBLE));
    registerFunction("exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE));
    registerFunction("ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE));
    registerFunction("sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE));
    registerFunction("sinh", new StandardSQLFunction("sinh", StandardBasicTypes.DOUBLE));
    registerFunction("stddev", new StandardSQLFunction("stddev", StandardBasicTypes.DOUBLE));
    registerFunction("sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE));
    registerFunction("tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE));
    registerFunction("tanh", new StandardSQLFunction("tanh", StandardBasicTypes.DOUBLE));
    registerFunction("variance", new StandardSQLFunction("variance", StandardBasicTypes.DOUBLE));
    registerFunction("round", new StandardSQLFunction("round"));
    registerFunction("trunc", new StandardSQLFunction("trunc"));
    registerFunction("ceil", new StandardSQLFunction("ceil"));
    registerFunction("floor", new StandardSQLFunction("floor"));
    registerFunction("chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER));
    registerFunction("initcap", new StandardSQLFunction("initcap"));
    registerFunction("lower", new StandardSQLFunction("lower"));
    registerFunction("ltrim", new StandardSQLFunction("ltrim"));
    registerFunction("rtrim", new StandardSQLFunction("rtrim"));
    registerFunction("soundex", new StandardSQLFunction("soundex"));
    registerFunction("upper", new StandardSQLFunction("upper"));
    registerFunction("ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER));
    registerFunction("to_char", new StandardSQLFunction("to_char", StandardBasicTypes.STRING));
    registerFunction("to_date", new StandardSQLFunction("to_date", StandardBasicTypes.TIMESTAMP));
    registerFunction("current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false));
    registerFunction("current_time", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIME, false));
    registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false));
    registerFunction("last_day", new StandardSQLFunction("last_day", StandardBasicTypes.DATE));
    registerFunction("sysdate", new NoArgSQLFunction("sysdate", StandardBasicTypes.DATE, false));
    registerFunction("systimestamp", new NoArgSQLFunction("systimestamp", StandardBasicTypes.TIMESTAMP, false));
    registerFunction("uid", new NoArgSQLFunction("uid", StandardBasicTypes.INTEGER, false));
    registerFunction("user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false));
    registerFunction("rowid", new NoArgSQLFunction("rowid", StandardBasicTypes.LONG, false));
    registerFunction("rownum", new NoArgSQLFunction("rownum", StandardBasicTypes.LONG, false));
    // Multi-param string dialect functions...
    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("instr", new StandardSQLFunction("instr", StandardBasicTypes.INTEGER));
    registerFunction("instrb", new StandardSQLFunction("instrb", StandardBasicTypes.INTEGER));
    registerFunction("lpad", new StandardSQLFunction("lpad", StandardBasicTypes.STRING));
    registerFunction("replace", new StandardSQLFunction("replace", StandardBasicTypes.STRING));
    registerFunction("rpad", new StandardSQLFunction("rpad", StandardBasicTypes.STRING));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("substrb", new StandardSQLFunction("substrb", StandardBasicTypes.STRING));
    registerFunction("translate", new StandardSQLFunction("translate", StandardBasicTypes.STRING));
    registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("locate", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "instr(?2,?1)"));
    registerFunction("bit_length", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "vsize(?1)*8"));
    registerFunction("coalesce", new NvlFunction());
    // Multi-param numeric dialect functions...
    registerFunction("atan2", new StandardSQLFunction("atan2", StandardBasicTypes.FLOAT));
    registerFunction("log", new StandardSQLFunction("log", StandardBasicTypes.INTEGER));
    registerFunction("mod", new StandardSQLFunction("mod", StandardBasicTypes.INTEGER));
    registerFunction("nvl", new StandardSQLFunction("nvl"));
    registerFunction("nvl2", new StandardSQLFunction("nvl2"));
    registerFunction("power", new StandardSQLFunction("power", StandardBasicTypes.FLOAT));
    // Multi-param date dialect functions...
    registerFunction("add_months", new StandardSQLFunction("add_months", StandardBasicTypes.DATE));
    registerFunction("months_between", new StandardSQLFunction("months_between", StandardBasicTypes.FLOAT));
    registerFunction("next_day", new StandardSQLFunction("next_day", StandardBasicTypes.DATE));
    registerFunction("str", new StandardSQLFunction("to_char", StandardBasicTypes.STRING));
}
Also used : VarArgsSQLFunction(org.hibernate.dialect.function.VarArgsSQLFunction) StandardSQLFunction(org.hibernate.dialect.function.StandardSQLFunction) NoArgSQLFunction(org.hibernate.dialect.function.NoArgSQLFunction) SQLFunctionTemplate(org.hibernate.dialect.function.SQLFunctionTemplate) NvlFunction(org.hibernate.dialect.function.NvlFunction)

Aggregations

NoArgSQLFunction (org.hibernate.dialect.function.NoArgSQLFunction)3 NvlFunction (org.hibernate.dialect.function.NvlFunction)2 SQLFunctionTemplate (org.hibernate.dialect.function.SQLFunctionTemplate)2 StandardSQLFunction (org.hibernate.dialect.function.StandardSQLFunction)2 VarArgsSQLFunction (org.hibernate.dialect.function.VarArgsSQLFunction)2 ConditionalParenthesisFunction (org.hibernate.dialect.function.ConditionalParenthesisFunction)1 ConvertFunction (org.hibernate.dialect.function.ConvertFunction)1 StandardJDBCEscapeFunction (org.hibernate.dialect.function.StandardJDBCEscapeFunction)1