Example usage for org.hibernate.dialect.function CharIndexFunction CharIndexFunction

List of usage examples for org.hibernate.dialect.function CharIndexFunction CharIndexFunction

Introduction

In this page you can find the example usage for org.hibernate.dialect.function CharIndexFunction CharIndexFunction.

Prototype

CharIndexFunction

Source Link

Usage

From source file:hacks.VirtuosoSybaseDialect.java

License:Open Source License

public VirtuosoSybaseDialect() {
    super();/*  w  w w. j av a  2 s.co  m*/
    registerColumnType(Types.BIT, "smallint"); //Sybase BIT type does not support null values
    //registerColumnType( Types.BIGINT, "numeric(19,0)" );
    registerColumnType(Types.BIGINT, "decimal");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.INTEGER, "int");
    registerColumnType(Types.CHAR, "char(1)");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.DOUBLE, "double precision");
    registerColumnType(Types.DATE, "datetime");
    registerColumnType(Types.TIME, "datetime");
    registerColumnType(Types.TIMESTAMP, "datetime");
    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);
}