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

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

Introduction

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

Prototype

AbstractAnsiTrimEmulationFunction

Source Link

Usage

From source file:com.enigmabridge.hibernate.dialect.SQLiteDialect.java

License:unlicense.org

public SQLiteDialect() {
    registerColumnType(Types.BIT, "boolean");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric($p, $s)");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "datetime");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "boolean");

    registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2"));
    registerFunction("quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING));
    registerFunction("random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER));
    registerFunction("round", new StandardSQLFunction("round"));
    registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
    registerFunction("trim", new AbstractAnsiTrimEmulationFunction() {
        protected SQLFunction resolveBothSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
        }/*from w w  w. ja  va  2s.  c  o m*/

        protected SQLFunction resolveBothSpaceTrimFromFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)");
        }

        protected SQLFunction resolveLeadingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)");
        }

        protected SQLFunction resolveTrailingSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)");
        }

        protected SQLFunction resolveBothTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)");
        }

        protected SQLFunction resolveLeadingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)");
        }

        protected SQLFunction resolveTrailingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
        }
    });
    uniqueDelegate = new SQLiteUniqueDelegate(this);
}