org.hibernate.dialect.function.StandardSQLFunction Java Examples

The following examples show how to use org.hibernate.dialect.function.StandardSQLFunction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SQLServerDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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");
}
 
Example #2
Source File: SQLServerDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a SQLServerDialect
 */
public SQLServerDialect() {
	registerColumnType( Types.VARBINARY, "image" );
	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" );
	registerKeyword( "key" );

	this.limitHandler = new TopLimitHandler( false, false );
}
 
Example #3
Source File: PostgresPlusDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a PostgresPlusDialect
 */
public PostgresPlusDialect() {
	super();

	registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
	registerFunction( "rtrim", new StandardSQLFunction( "rtrim" ) );
	registerFunction( "soundex", new StandardSQLFunction( "soundex" ) );
	registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", StandardBasicTypes.DATE, false ) );
	registerFunction( "rowid", new NoArgSQLFunction( "rowid", StandardBasicTypes.LONG, false ) );
	registerFunction( "rownum", new NoArgSQLFunction( "rownum", StandardBasicTypes.LONG, false ) );
	registerFunction( "instr", new StandardSQLFunction( "instr", StandardBasicTypes.INTEGER ) );
	registerFunction( "lpad", new StandardSQLFunction( "lpad", StandardBasicTypes.STRING ) );
	registerFunction( "replace", new StandardSQLFunction( "replace", StandardBasicTypes.STRING ) );
	registerFunction( "rpad", new StandardSQLFunction( "rpad", StandardBasicTypes.STRING ) );
	registerFunction( "translate", new StandardSQLFunction( "translate", StandardBasicTypes.STRING ) );
	registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
	registerFunction( "coalesce", new NvlFunction() );
	registerFunction( "atan2", new StandardSQLFunction( "atan2", StandardBasicTypes.FLOAT ) );
	registerFunction( "mod", new StandardSQLFunction( "mod", StandardBasicTypes.INTEGER ) );
	registerFunction( "nvl", new StandardSQLFunction( "nvl" ) );
	registerFunction( "nvl2", new StandardSQLFunction( "nvl2" ) );
	registerFunction( "power", new StandardSQLFunction( "power", StandardBasicTypes.FLOAT ) );
	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 ) );
}
 
Example #4
Source File: SQLiteDialect.java    From oim-fx with MIT License 5 votes vote down vote up
public SQLiteDialect() {
	super();
	registerColumnType(Types.BIT, "integer");
	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");
	registerColumnType(Types.DECIMAL, "decimal");
	registerColumnType(Types.CHAR, "char");
	registerColumnType(Types.VARCHAR, "varchar");
	registerColumnType(Types.LONGVARCHAR, "longvarchar");
	registerColumnType(Types.DATE, "date");
	registerColumnType(Types.TIME, "time");
	registerColumnType(Types.TIMESTAMP, "timestamp");
	registerColumnType(Types.BINARY, "blob");
	registerColumnType(Types.VARBINARY, "blob");
	registerColumnType(Types.LONGVARBINARY, "blob");
	// registerColumnType(Types.NULL, "null");
	registerColumnType(Types.BLOB, "blob");
	registerColumnType(Types.CLOB, "clob");
	registerColumnType(Types.BOOLEAN, "integer");

	registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", ""));
	registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2"));
	registerFunction("substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
	registerFunction("substring", new StandardSQLFunction("substr", StandardBasicTypes.STRING));
}
 
Example #5
Source File: SQLiteDialect.java    From poli-libras with GNU General Public License v3.0 5 votes vote down vote up
public SQLiteDialect() {
	super();
	registerColumnType(Types.BIT, "integer");
	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");
	registerColumnType(Types.DECIMAL, "decimal");
	registerColumnType(Types.CHAR, "char");
	registerColumnType(Types.VARCHAR, "varchar");
	registerColumnType(Types.LONGVARCHAR, "longvarchar");
	registerColumnType(Types.DATE, "date");
	registerColumnType(Types.TIME, "time");
	registerColumnType(Types.TIMESTAMP, "timestamp");
	registerColumnType(Types.BINARY, "blob");
	registerColumnType(Types.VARBINARY, "blob");
	registerColumnType(Types.LONGVARBINARY, "blob");
	// registerColumnType(Types.NULL, "null");
	registerColumnType(Types.BLOB, "blob");
	registerColumnType(Types.CLOB, "clob");
	registerColumnType(Types.BOOLEAN, "integer");

	 registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
	 registerFunction( "mod", new SQLFunctionTemplate( Hibernate.INTEGER, "?1 % ?2" ) );
	 registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
	 registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
}
 
Example #6
Source File: HibernateUtil.java    From unitime with Apache License 2.0 5 votes vote down vote up
public static void addBitwiseOperationsToDialect() {
	SessionFactoryImplementor hibSessionFactory = (SessionFactoryImplementor)new _RootDAO().getSession().getSessionFactory();
	Dialect dialect = hibSessionFactory.getDialect();
	if (!dialect.getFunctions().containsKey("bit_and")) {
		if (isOracle())
			dialect.getFunctions().put("bit_and", new StandardSQLFunction("bitand", IntegerType.INSTANCE));
		else if (isPostgress())
			dialect.getFunctions().put("bit_and", new SQLFunctionTemplate(IntegerType.INSTANCE, "cast(?1 as int) & cast(?2 as int)"));
		else
			dialect.getFunctions().put("bit_and", new SQLFunctionTemplate(IntegerType.INSTANCE, "?1 & ?2"));
	}
}
 
Example #7
Source File: SQLiteDialect.java    From webdsl with Apache License 2.0 5 votes vote down vote up
public SQLiteDialect() {
	super();
	registerColumnType(Types.BIT, "integer");
	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");
	registerColumnType(Types.DECIMAL, "decimal");
	registerColumnType(Types.CHAR, "char");
	registerColumnType(Types.VARCHAR, "varchar");
	registerColumnType(Types.LONGVARCHAR, "longvarchar");
	registerColumnType(Types.DATE, "date");
	registerColumnType(Types.TIME, "time");
	registerColumnType(Types.TIMESTAMP, "timestamp");
	registerColumnType(Types.BINARY, "blob");
	registerColumnType(Types.VARBINARY, "blob");
	registerColumnType(Types.LONGVARBINARY, "blob");
	// registerColumnType(Types.NULL, "null");
	registerColumnType(Types.BLOB, "blob");
	registerColumnType(Types.CLOB, "clob");
	registerColumnType(Types.BOOLEAN, "integer");

	registerFunction("concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "",
			"||", ""));
	registerFunction("mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER,
			"?1 % ?2"));
	registerFunction("substr", new StandardSQLFunction("substr",
			StandardBasicTypes.STRING));
	registerFunction("substring", new StandardSQLFunction("substr",
			StandardBasicTypes.STRING));
}
 
Example #8
Source File: GroupConcatFunctionMetadataRegisterTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Override
protected void additionalMetadata(MetadataBuilder metadataBuilder) {
    metadataBuilder.applySqlFunction(
        "group_concat",
        new StandardSQLFunction("group_concat", StandardBasicTypes.STRING)
    );
}
 
Example #9
Source File: GroupConcatFunctionDialectRegisterTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
public CustomMySQLDialect() {
    super();

    registerFunction(
            "group_concat",
            new StandardSQLFunction("group_concat", StandardBasicTypes.STRING)
    );
}
 
Example #10
Source File: GroupConcatFunctionMetadataBuilderContributorRegisterTest.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Override
public void contribute(MetadataBuilder metadataBuilder) {
    metadataBuilder.applySqlFunction(
        "group_concat",
        new StandardSQLFunction("group_concat", StandardBasicTypes.STRING)
    );
}
 
Example #11
Source File: MckoiDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public MckoiDialect() {
	super();
	registerColumnType( Types.BIT, "bit" );
	registerColumnType( Types.BIGINT, "bigint" );
	registerColumnType( Types.SMALLINT, "smallint" );
	registerColumnType( Types.TINYINT, "tinyint" );
	registerColumnType( Types.INTEGER, "integer" );
	registerColumnType( Types.CHAR, "char(1)" );
	registerColumnType( Types.VARCHAR, "varchar($l)" );
	registerColumnType( Types.FLOAT, "float" );
	registerColumnType( Types.DOUBLE, "double" );
	registerColumnType( Types.DATE, "date" );
	registerColumnType( Types.TIME, "time" );
	registerColumnType( Types.TIMESTAMP, "timestamp" );
	registerColumnType( Types.VARBINARY, "varbinary" );
	registerColumnType( Types.NUMERIC, "numeric" );
	registerColumnType( Types.BLOB, "blob" );
	registerColumnType( Types.CLOB, "clob" );

	registerFunction( "upper", new StandardSQLFunction("upper") );
	registerFunction( "lower", new StandardSQLFunction("lower") );
	registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
	registerFunction( "abs", new StandardSQLFunction("abs") );
	registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
	registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
	registerFunction( "round", new StandardSQLFunction( "round", Hibernate.INTEGER ) );
	registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER ) );
	registerFunction( "least", new StandardSQLFunction("least") );
	registerFunction( "greatest", new StandardSQLFunction("greatest") );
	registerFunction( "user", new StandardSQLFunction( "user", Hibernate.STRING ) );
	registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );

	getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
}
 
Example #12
Source File: TimesTenDialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public TimesTenDialect() {
	super();
	registerColumnType( Types.BIT, "TINYINT" );
	registerColumnType( Types.BIGINT, "BIGINT" );
	registerColumnType( Types.SMALLINT, "SMALLINT" );
	registerColumnType( Types.TINYINT, "TINYINT" );
	registerColumnType( Types.INTEGER, "INTEGER" );
	registerColumnType( Types.CHAR, "CHAR(1)" );
	registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
	registerColumnType( Types.FLOAT, "FLOAT" );
	registerColumnType( Types.DOUBLE, "DOUBLE" );
	registerColumnType( Types.DATE, "DATE" );
	registerColumnType( Types.TIME, "TIME" );
	registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
	registerColumnType( Types.VARBINARY, "VARBINARY($l)" );
	registerColumnType( Types.NUMERIC, "DECIMAL($p, $s)" );
	// TimesTen has no BLOB/CLOB support, but these types may be suitable
	// for some applications. The length is limited to 4 million bytes.
       registerColumnType( Types.BLOB, "VARBINARY(4000000)" );
       registerColumnType( Types.CLOB, "VARCHAR(4000000)" );

	getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
	getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
	registerFunction( "lower", new StandardSQLFunction("lower") );
	registerFunction( "upper", new StandardSQLFunction("upper") );
	registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
	registerFunction( "concat", new StandardSQLFunction("concat", Hibernate.STRING) );
	registerFunction( "mod", new StandardSQLFunction("mod") );
	registerFunction( "to_char", new StandardSQLFunction("to_char",Hibernate.STRING) );
	registerFunction( "to_date", new StandardSQLFunction("to_date",Hibernate.TIMESTAMP) );
	registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP, false) );
	registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP, false) );
	registerFunction( "nvl", new StandardSQLFunction("nvl") );

}
 
Example #13
Source File: DhisPostgresDialect.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public DhisPostgresDialect()
{
    registerColumnType( Types.JAVA_OBJECT, "jsonb" );
    registerHibernateType( Types.OTHER, "pg-uuid" );
    registerFunction( "jsonb_extract_path", new StandardSQLFunction( "jsonb_extract_path", StandardBasicTypes.STRING ) );
    registerFunction( "jsonb_extract_path_text", new StandardSQLFunction( "jsonb_extract_path_text", StandardBasicTypes.STRING ) );
}
 
Example #14
Source File: SQLiteDialect.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
public SQLiteDialect() {
	super();
	registerColumnType(Types.BIT, "integer");
	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");
	registerColumnType(Types.DECIMAL, "decimal");
	registerColumnType(Types.CHAR, "char");
	registerColumnType(Types.VARCHAR, 255, "varchar($l)");
	registerColumnType(Types.LONGVARCHAR, "longvarchar");
	registerColumnType(Types.DATE, "date");
	registerColumnType(Types.TIME, "time");
	registerColumnType(Types.TIMESTAMP, "timestamp");
	registerColumnType(Types.BINARY, "blob");
	registerColumnType(Types.VARBINARY, "blob");
	registerColumnType(Types.LONGVARBINARY, "blob");
	registerColumnType(Types.BLOB, "blob");
	registerColumnType(Types.CLOB, "clob");
	registerColumnType(Types.BOOLEAN, "integer");
	registerHibernateType(Types.NULL, "null");
	
	registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE,
			"", "||", ""));
	registerFunction("mod", new SQLFunctionTemplate(IntegerType.INSTANCE,
			"?1 % ?2"));
	registerFunction("substr", new StandardSQLFunction("substr",
			StringType.INSTANCE));
	registerFunction("substring", new StandardSQLFunction("substr",
			StringType.INSTANCE));
}
 
Example #15
Source File: CustomOracleSpatialDialect.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public CustomOracleSpatialDialect() {
	super();

	InlineFunctionRegistrationManager.registerInlineFunctions(this);

	registerFunction("dwithin", new StandardSQLFunction("SDO_WITHIN_DISTANCE", StandardBasicTypes.STRING));
	registerFunction("spatial_contains", new StandardSQLFunction("SDO_CONTAINS", StandardBasicTypes.BOOLEAN));
	registerFunction("intersection", new StandardSQLFunction("SDO_GEOM.SDO_INTERSECTION", GeometryUserType.TYPE));
	registerFunction("spatial_nn", new StandardSQLFunction("SDO_NN", StandardBasicTypes.BIG_DECIMAL));
	registerFunction("length_spa", new StandardSQLFunction("SDO_GEOM.SDO_LENGTH", StandardBasicTypes.BIG_DECIMAL));
	registerFunction("filter", new StandardSQLFunction("SDO_FILTER", StandardBasicTypes.STRING));
	registerFunction("distance", new StandardSQLFunction("SDO_GEOM.SDO_DISTANCE", StandardBasicTypes.BIG_DECIMAL));
	registerFunction("union", new StandardSQLFunction("SDO_GEOM.SDO_UNION", GeometryUserType.TYPE));
	registerFunction("centroid", new StandardSQLFunction("SDO_GEOM.SDO_CENTROID", GeometryUserType.TYPE));
	registerFunction("covers", new StandardSQLFunction("SDO_COVERS", StandardBasicTypes.STRING));
	registerFunction("coveredby", new StandardSQLFunction("SDO_COVEREDBY", StandardBasicTypes.STRING));
	registerFunction("relate", new StandardSQLFunction("SDO_GEOM.RELATE", StandardBasicTypes.STRING));
	registerFunction("inside", new StandardSQLFunction("SDO_INSIDE", StandardBasicTypes.STRING));
	registerFunction("to_km", new SQLFunctionTemplate(StandardBasicTypes.BIG_DECIMAL, "((?1) * 1.852)"));
	registerFunction("to_nm", new SQLFunctionTemplate(StandardBasicTypes.BIG_DECIMAL, "((?1) / 1.852)"));
	registerFunction("extract", new SQLFunctionTemplate(StandardBasicTypes.LONG, "extract (?1 from (?2))"));
	registerFunction("to_timezone", new SQLFunctionTemplate(StandardBasicTypes.TIMESTAMP, "((?1) + ?2/24)") {
		@Override
		public String render(Type argumentType, List args, SessionFactoryImplementor factory) {
			if (args == null || args.size() != 2) {
				throw new QueryException("to_timezone() requires two arguments");
			}
			if (!((String) args.get(1)).matches("\\-?((1?[0-9])|(2[0-3]))")) {
				throw new QueryException("to_timezone()'s second parameter must be a number from -23 to +23");
			}
			return super.render(argumentType, args, factory);
		}
	});
	registerFunction("latitude", new SQLFunctionTemplate(StandardBasicTypes.STRING, "CASE ?1.Get_GType() WHEN 1 THEN to_char(?1.sdo_point.y) ELSE '' END"));
	registerFunction("longitude",
			new SQLFunctionTemplate(StandardBasicTypes.STRING, "CASE ?1.Get_GType() WHEN 1 THEN to_char(?1.sdo_point.x) ELSE '' END"));
}
 
Example #16
Source File: SQLiteDialect.java    From MonitorClient with Apache License 2.0 5 votes vote down vote up
public SQLiteDialect() {
    registerColumnType(Types.BIT, "integer");
    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");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction( "concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", "") );
    registerFunction( "mod", new SQLFunctionTemplate( StringType.INSTANCE, "?1 % ?2" ) );
    registerFunction( "substr", new StandardSQLFunction("substr", StringType.INSTANCE) );
    registerFunction( "substring", new StandardSQLFunction( "substr", StringType.INSTANCE) );
}
 
Example #17
Source File: MckoiDialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a MckoiDialect
 */
public MckoiDialect() {
	super();
	registerColumnType( Types.BIT, "bit" );
	registerColumnType( Types.BIGINT, "bigint" );
	registerColumnType( Types.SMALLINT, "smallint" );
	registerColumnType( Types.TINYINT, "tinyint" );
	registerColumnType( Types.INTEGER, "integer" );
	registerColumnType( Types.CHAR, "char(1)" );
	registerColumnType( Types.VARCHAR, "varchar($l)" );
	registerColumnType( Types.FLOAT, "float" );
	registerColumnType( Types.DOUBLE, "double" );
	registerColumnType( Types.DATE, "date" );
	registerColumnType( Types.TIME, "time" );
	registerColumnType( Types.TIMESTAMP, "timestamp" );
	registerColumnType( Types.VARBINARY, "varbinary" );
	registerColumnType( Types.NUMERIC, "numeric" );
	registerColumnType( Types.BLOB, "blob" );
	registerColumnType( Types.CLOB, "clob" );

	registerFunction( "upper", new StandardSQLFunction("upper") );
	registerFunction( "lower", new StandardSQLFunction("lower") );
	registerFunction( "sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE) );
	registerFunction( "abs", new StandardSQLFunction("abs") );
	registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) );
	registerFunction( "round", new StandardSQLFunction( "round", StandardBasicTypes.INTEGER ) );
	registerFunction( "mod", new StandardSQLFunction( "mod", StandardBasicTypes.INTEGER ) );
	registerFunction( "least", new StandardSQLFunction("least") );
	registerFunction( "greatest", new StandardSQLFunction("greatest") );
	registerFunction( "user", new StandardSQLFunction( "user", StandardBasicTypes.STRING ) );
	registerFunction( "concat", new StandardSQLFunction( "concat", StandardBasicTypes.STRING ) );

	getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
 
Example #18
Source File: PostgreSQL94Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a PostgreSQL94Dialect
 */
public PostgreSQL94Dialect() {
	super();
	registerFunction( "make_interval", new StandardSQLFunction("make_interval", StandardBasicTypes.TIMESTAMP) );
	registerFunction( "make_timestamp", new StandardSQLFunction("make_timestamp", StandardBasicTypes.TIMESTAMP) );
	registerFunction( "make_timestamptz", new StandardSQLFunction("make_timestamptz", StandardBasicTypes.TIMESTAMP) );
	registerFunction( "make_date", new StandardSQLFunction("make_date", StandardBasicTypes.DATE) );
	registerFunction( "make_time", new StandardSQLFunction("make_time", StandardBasicTypes.TIME) );
}
 
Example #19
Source File: MariaDB10Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public MariaDB10Dialect() {
	super();

	registerFunction( "regexp_replace", new StandardSQLFunction( "regexp_replace", StandardBasicTypes.STRING ) );
	registerFunction( "regexp_instr", new StandardSQLFunction( "regexp_instr", StandardBasicTypes.INTEGER ) );
	registerFunction( "regexp_substr", new StandardSQLFunction( "regexp_substr", StandardBasicTypes.STRING ) );
	registerFunction( "weight_string", new StandardSQLFunction( "weight_string", StandardBasicTypes.STRING ) );
	registerFunction( "to_base64", new StandardSQLFunction( "to_base64", StandardBasicTypes.STRING ) );
	registerFunction( "from_base64", new StandardSQLFunction( "from_base64", StandardBasicTypes.STRING ) );
}
 
Example #20
Source File: SQLiteDialect.java    From springboot-sqlite-mini-website with Apache License 2.0 5 votes vote down vote up
public SQLiteDialect() {
    registerColumnType(Types.BIT, "integer");
    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");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "timestamp");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    // registerColumnType(Types.NULL, "null");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "integer");

    registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", ""));
    registerFunction("mod", new SQLFunctionTemplate(StringType.INSTANCE, "?1 % ?2"));
    registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE));
    registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE));
}
 
Example #21
Source File: TimesTenDialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a TimesTenDialect
 */
public TimesTenDialect() {
	super();
	registerColumnType( Types.BIT, "TINYINT" );
	registerColumnType( Types.BIGINT, "BIGINT" );
	registerColumnType( Types.SMALLINT, "SMALLINT" );
	registerColumnType( Types.TINYINT, "TINYINT" );
	registerColumnType( Types.INTEGER, "INTEGER" );
	registerColumnType( Types.CHAR, "CHAR(1)" );
	registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
	registerColumnType( Types.FLOAT, "FLOAT" );
	registerColumnType( Types.DOUBLE, "DOUBLE" );
	registerColumnType( Types.DATE, "DATE" );
	registerColumnType( Types.TIME, "TIME" );
	registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
	registerColumnType( Types.VARBINARY, "VARBINARY($l)" );
	registerColumnType( Types.NUMERIC, "DECIMAL($p, $s)" );
	// TimesTen has no BLOB/CLOB support, but these types may be suitable 
	// for some applications. The length is limited to 4 million bytes.
	registerColumnType( Types.BLOB, "VARBINARY(4000000)" );
	registerColumnType( Types.CLOB, "VARCHAR(4000000)" );

	getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
	getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
	registerFunction( "lower", new StandardSQLFunction( "lower" ) );
	registerFunction( "upper", new StandardSQLFunction( "upper" ) );
	registerFunction( "rtrim", new StandardSQLFunction( "rtrim" ) );
	registerFunction( "concat", new StandardSQLFunction( "concat", StandardBasicTypes.STRING ) );
	registerFunction( "mod", new StandardSQLFunction( "mod" ) );
	registerFunction( "to_char", new StandardSQLFunction( "to_char", StandardBasicTypes.STRING ) );
	registerFunction( "to_date", new StandardSQLFunction( "to_date", StandardBasicTypes.TIMESTAMP ) );
	registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", StandardBasicTypes.TIMESTAMP, false ) );
	registerFunction( "getdate", new NoArgSQLFunction( "getdate", StandardBasicTypes.TIMESTAMP, false ) );
	registerFunction( "nvl", new StandardSQLFunction( "nvl" ) );
}
 
Example #22
Source File: SAPDBDialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a SAPDBDialect
 */
public SAPDBDialect() {
	super();
	registerColumnType( Types.BIT, "boolean" );
	registerColumnType( Types.BIGINT, "fixed(19,0)" );
	registerColumnType( Types.SMALLINT, "smallint" );
	registerColumnType( Types.TINYINT, "fixed(3,0)" );
	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, "date" );
	registerColumnType( Types.TIME, "time" );
	registerColumnType( Types.TIMESTAMP, "timestamp" );
	registerColumnType( Types.VARBINARY, "long byte" );
	registerColumnType( Types.NUMERIC, "fixed($p,$s)" );
	registerColumnType( Types.CLOB, "long varchar" );
	registerColumnType( Types.BLOB, "long byte" );

	registerFunction( "abs", new StandardSQLFunction( "abs" ) );
	registerFunction( "sign", new StandardSQLFunction( "sign", StandardBasicTypes.INTEGER ) );

	registerFunction( "exp", new StandardSQLFunction( "exp", StandardBasicTypes.DOUBLE ) );
	registerFunction( "ln", new StandardSQLFunction( "ln", StandardBasicTypes.DOUBLE ) );
	registerFunction( "log", new StandardSQLFunction( "ln", StandardBasicTypes.DOUBLE ) );
	registerFunction( "pi", new NoArgSQLFunction( "pi", StandardBasicTypes.DOUBLE ) );
	registerFunction( "power", new StandardSQLFunction( "power" ) );
	registerFunction( "acos", new StandardSQLFunction( "acos", StandardBasicTypes.DOUBLE ) );
	registerFunction( "asin", new StandardSQLFunction( "asin", StandardBasicTypes.DOUBLE ) );
	registerFunction( "atan", new StandardSQLFunction( "atan", StandardBasicTypes.DOUBLE ) );
	registerFunction( "cos", new StandardSQLFunction( "cos", StandardBasicTypes.DOUBLE ) );
	registerFunction( "cosh", new StandardSQLFunction( "cosh", StandardBasicTypes.DOUBLE ) );
	registerFunction( "cot", new StandardSQLFunction( "cos", StandardBasicTypes.DOUBLE ) );
	registerFunction( "sin", new StandardSQLFunction( "sin", StandardBasicTypes.DOUBLE ) );
	registerFunction( "sinh", new StandardSQLFunction( "sinh", StandardBasicTypes.DOUBLE ) );
	registerFunction( "tan", new StandardSQLFunction( "tan", StandardBasicTypes.DOUBLE ) );
	registerFunction( "tanh", new StandardSQLFunction( "tanh", StandardBasicTypes.DOUBLE ) );
	registerFunction( "radians", new StandardSQLFunction( "radians", StandardBasicTypes.DOUBLE ) );
	registerFunction( "degrees", new StandardSQLFunction( "degrees", StandardBasicTypes.DOUBLE ) );
	registerFunction( "atan2", new StandardSQLFunction( "atan2", StandardBasicTypes.DOUBLE ) );

	registerFunction( "round", new StandardSQLFunction( "round" ) );
	registerFunction( "trunc", new StandardSQLFunction( "trunc" ) );
	registerFunction( "ceil", new StandardSQLFunction( "ceil" ) );
	registerFunction( "floor", new StandardSQLFunction( "floor" ) );
	registerFunction( "greatest", new StandardSQLFunction( "greatest" ) );
	registerFunction( "least", new StandardSQLFunction( "least" ) );

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

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

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

	registerFunction( "dayname", new StandardSQLFunction( "dayname", StandardBasicTypes.STRING ) );
	registerFunction( "monthname", new StandardSQLFunction( "monthname", StandardBasicTypes.STRING ) );
	registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", StandardBasicTypes.INTEGER ) );
	registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", StandardBasicTypes.INTEGER ) );
	registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", StandardBasicTypes.INTEGER ) );
	registerFunction( "weekofyear", new StandardSQLFunction( "weekofyear", StandardBasicTypes.INTEGER ) );

	registerFunction( "replace", new StandardSQLFunction( "replace", StandardBasicTypes.STRING ) );
	registerFunction( "translate", new StandardSQLFunction( "translate", StandardBasicTypes.STRING ) );
	registerFunction( "lpad", new StandardSQLFunction( "lpad", StandardBasicTypes.STRING ) );
	registerFunction( "rpad", new StandardSQLFunction( "rpad", StandardBasicTypes.STRING ) );
	registerFunction( "substr", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
	registerFunction( "initcap", new StandardSQLFunction( "initcap", StandardBasicTypes.STRING ) );
	registerFunction( "lower", new StandardSQLFunction( "lower", StandardBasicTypes.STRING ) );
	registerFunction( "ltrim", new StandardSQLFunction( "ltrim", StandardBasicTypes.STRING ) );
	registerFunction( "rtrim", new StandardSQLFunction( "rtrim", StandardBasicTypes.STRING ) );
	registerFunction( "lfill", new StandardSQLFunction( "ltrim", StandardBasicTypes.STRING ) );
	registerFunction( "rfill", new StandardSQLFunction( "rtrim", StandardBasicTypes.STRING ) );
	registerFunction( "soundex", new StandardSQLFunction( "soundex", StandardBasicTypes.STRING ) );
	registerFunction( "upper", new StandardSQLFunction( "upper", StandardBasicTypes.STRING ) );
	registerFunction( "ascii", new StandardSQLFunction( "ascii", StandardBasicTypes.STRING ) );
	registerFunction( "index", new StandardSQLFunction( "index", StandardBasicTypes.INTEGER ) );

	registerFunction( "value", new StandardSQLFunction( "value" ) );

	registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
	registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
	registerFunction( "locate", new StandardSQLFunction( "index", StandardBasicTypes.INTEGER ) );
	registerFunction( "coalesce", new StandardSQLFunction( "value" ) );

	getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );

}
 
Example #23
Source File: Dialect.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
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() );
	registerHibernateType( Types.CHAR, Hibernate.CHARACTER.getName() );
	registerHibernateType( Types.DATE, Hibernate.DATE.getName() );
	registerHibernateType( Types.DOUBLE, Hibernate.DOUBLE.getName() );
	registerHibernateType( Types.FLOAT, Hibernate.FLOAT.getName() );
	registerHibernateType( Types.INTEGER, Hibernate.INTEGER.getName() );
	registerHibernateType( Types.SMALLINT, Hibernate.SHORT.getName() );
	registerHibernateType( Types.TINYINT, Hibernate.BYTE.getName() );
	registerHibernateType( Types.TIME, Hibernate.TIME.getName() );
	registerHibernateType( Types.TIMESTAMP, Hibernate.TIMESTAMP.getName() );
	registerHibernateType( Types.VARCHAR, Hibernate.STRING.getName() );
	registerHibernateType( Types.VARBINARY, Hibernate.BINARY.getName() );
	registerHibernateType( Types.NUMERIC, Hibernate.BIG_DECIMAL.getName() );
	registerHibernateType( Types.DECIMAL, Hibernate.BIG_DECIMAL.getName() );
	registerHibernateType( Types.BLOB, Hibernate.BLOB.getName() );
	registerHibernateType( Types.CLOB, Hibernate.CLOB.getName() );
	registerHibernateType( Types.REAL, Hibernate.FLOAT.getName() );
}
 
Example #24
Source File: GemFireXDDialect.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public GemFireXDDialect() {
	super();
        LOG.info("GemFireXDDialect for Hibernate 4.0 initialized.");
              
	registerFunction("concat", new DerbyConcatFunction());
	registerFunction("trim", new AnsiTrimFunction());
	registerFunction("value", new StandardSQLFunction("coalesce"));
	registerFunction("nvl", new NvlFunction());
	registerFunction("groups", new StandardSQLFunction("GROUPS",
			StandardBasicTypes.STRING));
	registerFunction("dsid", new StandardSQLFunction("DSID",
			StandardBasicTypes.STRING));
	registerFunction("groupsintersection", new StandardSQLFunction(
			"GROUPSINTERSECTION", StandardBasicTypes.STRING));
	registerFunction("groupsintersect", new StandardSQLFunction(
			"GROUPSINTERSECT", StandardBasicTypes.BOOLEAN));
	registerFunction("groupsunion", new StandardSQLFunction("GROUPSUNION",
			StandardBasicTypes.STRING));
	registerFunction("longint", new StandardSQLFunction("bigint",
			StandardBasicTypes.LONG));
	registerFunction("int", new StandardSQLFunction("integer",
			StandardBasicTypes.INTEGER));
	registerFunction("pi", new StandardSQLFunction("pi",
			StandardBasicTypes.DOUBLE));
	registerFunction("random", new NoArgSQLFunction("random",
			StandardBasicTypes.DOUBLE));
	registerFunction("rand", new StandardSQLFunction("rand",
			StandardBasicTypes.DOUBLE));// override
	registerFunction("sinh", new StandardSQLFunction("sinh",
			StandardBasicTypes.DOUBLE));
	registerFunction("cosh", new StandardSQLFunction("cosh",
			StandardBasicTypes.DOUBLE));
	registerFunction("tanh", new StandardSQLFunction("tanh",
			StandardBasicTypes.DOUBLE));
	registerFunction("user", new NoArgSQLFunction("USER",
			StandardBasicTypes.STRING, false));
	registerFunction("current_user", new NoArgSQLFunction("CURRENT_USER",
			StandardBasicTypes.STRING, false));
	registerFunction("session_user", new NoArgSQLFunction("SESSION_USER",
			StandardBasicTypes.STRING, false));
	registerFunction("current isolation", new NoArgSQLFunction(
			"CURRENT ISOLATION", StandardBasicTypes.STRING, false));
	registerFunction("current_role", new NoArgSQLFunction("CURRENT_ROLE",
			StandardBasicTypes.STRING, false));
	registerFunction("current schema", new NoArgSQLFunction(
			"CURRENT SCHEMA", StandardBasicTypes.STRING, false));
	registerFunction("current sqlid", new NoArgSQLFunction("CURRENT SQLID",
			StandardBasicTypes.STRING, false));
	registerFunction("xmlexists", new StandardSQLFunction("XMLEXISTS",
			StandardBasicTypes.NUMERIC_BOOLEAN));
	registerFunction("xmlparse", new StandardSQLFunction("XMLPARSE",
			StandardBasicTypes.TEXT));
	registerFunction("xmlquery", new StandardSQLFunction("XMLQUERY",
			StandardBasicTypes.STRING));
	registerFunction("xmlserialize", new StandardSQLFunction(
			"XMLSERIALIZE", StandardBasicTypes.STRING));
	registerFunction("get_current_connection", new NoArgSQLFunction(
			"GET_CURRENT_CONNECTION", StandardBasicTypes.BINARY, true));
	registerFunction("identity_val_local", new NoArgSQLFunction(
			"IDENTITY_VAL_LOCAL", StandardBasicTypes.BINARY, true));
}
 
Example #25
Source File: GemFireXDDialect.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public GemFireXDDialect() {
	super();
        LOG.info("GemFireXDDialect for Hibernate 4 initialized.");
              
	registerFunction("concat", new DerbyConcatFunction());
	registerFunction("trim", new AnsiTrimFunction());
	registerFunction("value", new StandardSQLFunction("coalesce"));
	registerFunction("nvl", new NvlFunction());
	registerFunction("groups", new StandardSQLFunction("GROUPS",
			StandardBasicTypes.STRING));
	registerFunction("dsid", new StandardSQLFunction("DSID",
			StandardBasicTypes.STRING));
	registerFunction("groupsintersection", new StandardSQLFunction(
			"GROUPSINTERSECTION", StandardBasicTypes.STRING));
	registerFunction("groupsintersect", new StandardSQLFunction(
			"GROUPSINTERSECT", StandardBasicTypes.BOOLEAN));
	registerFunction("groupsunion", new StandardSQLFunction("GROUPSUNION",
			StandardBasicTypes.STRING));
	registerFunction("longint", new StandardSQLFunction("bigint",
			StandardBasicTypes.LONG));
	registerFunction("int", new StandardSQLFunction("integer",
			StandardBasicTypes.INTEGER));
	registerFunction("pi", new StandardSQLFunction("pi",
			StandardBasicTypes.DOUBLE));
	registerFunction("random", new NoArgSQLFunction("random",
			StandardBasicTypes.DOUBLE));
	registerFunction("rand", new StandardSQLFunction("rand",
			StandardBasicTypes.DOUBLE));// override
	registerFunction("sinh", new StandardSQLFunction("sinh",
			StandardBasicTypes.DOUBLE));
	registerFunction("cosh", new StandardSQLFunction("cosh",
			StandardBasicTypes.DOUBLE));
	registerFunction("tanh", new StandardSQLFunction("tanh",
			StandardBasicTypes.DOUBLE));
	registerFunction("user", new NoArgSQLFunction("USER",
			StandardBasicTypes.STRING, false));
	registerFunction("current_user", new NoArgSQLFunction("CURRENT_USER",
			StandardBasicTypes.STRING, false));
	registerFunction("session_user", new NoArgSQLFunction("SESSION_USER",
			StandardBasicTypes.STRING, false));
	registerFunction("current isolation", new NoArgSQLFunction(
			"CURRENT ISOLATION", StandardBasicTypes.STRING, false));
	registerFunction("current_role", new NoArgSQLFunction("CURRENT_ROLE",
			StandardBasicTypes.STRING, false));
	registerFunction("current schema", new NoArgSQLFunction(
			"CURRENT SCHEMA", StandardBasicTypes.STRING, false));
	registerFunction("current sqlid", new NoArgSQLFunction("CURRENT SQLID",
			StandardBasicTypes.STRING, false));
	registerFunction("xmlexists", new StandardSQLFunction("XMLEXISTS",
			StandardBasicTypes.NUMERIC_BOOLEAN));
	registerFunction("xmlparse", new StandardSQLFunction("XMLPARSE",
			StandardBasicTypes.TEXT));
	registerFunction("xmlquery", new StandardSQLFunction("XMLQUERY",
			StandardBasicTypes.STRING));
	registerFunction("xmlserialize", new StandardSQLFunction(
			"XMLSERIALIZE", StandardBasicTypes.STRING));
	registerFunction("get_current_connection", new NoArgSQLFunction(
			"GET_CURRENT_CONNECTION", StandardBasicTypes.BINARY, true));
	registerFunction("identity_val_local", new NoArgSQLFunction(
			"IDENTITY_VAL_LOCAL", StandardBasicTypes.BINARY, true));
}
 
Example #26
Source File: GemFireXDDialect.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public GemFireXDDialect() {
	super();
	LOG.info("GemFireXDDialect for Hibernate 3.6 initialized.");
	    
	registerFunction("trim", new AnsiTrimFunction());
	registerFunction("concat", new DerbyConcatFunction());
	
               registerFunction("value", new StandardSQLFunction("coalesce"));
               registerFunction("nvl", new NvlFunction());
               registerFunction("groups", new StandardSQLFunction("GROUPS",
                   StandardBasicTypes.STRING));
               registerFunction("dsid", new StandardSQLFunction("DSID",
                   StandardBasicTypes.STRING));
               registerFunction("groupsintersection", new StandardSQLFunction(
                   "GROUPSINTERSECTION", StandardBasicTypes.STRING));
               registerFunction("groupsintersect", new StandardSQLFunction(
                   "GROUPSINTERSECT", StandardBasicTypes.BOOLEAN));
               registerFunction("groupsunion", new StandardSQLFunction("GROUPSUNION",
                   StandardBasicTypes.STRING));
               registerFunction("longint", new StandardSQLFunction("bigint",
                   StandardBasicTypes.LONG));
               registerFunction("int", new StandardSQLFunction("integer",
                   StandardBasicTypes.INTEGER));
               registerFunction("pi", new StandardSQLFunction("pi",
                   StandardBasicTypes.DOUBLE));
               registerFunction("random", new NoArgSQLFunction("random",
                   StandardBasicTypes.DOUBLE));
               registerFunction("rand", new StandardSQLFunction("rand",
                   StandardBasicTypes.DOUBLE));// override
               registerFunction("sinh", new StandardSQLFunction("sinh",
                   StandardBasicTypes.DOUBLE));
               registerFunction("cosh", new StandardSQLFunction("cosh",
                   StandardBasicTypes.DOUBLE));
               registerFunction("tanh", new StandardSQLFunction("tanh",
                   StandardBasicTypes.DOUBLE));
               registerFunction("user", new NoArgSQLFunction("USER",
                   StandardBasicTypes.STRING, false));
               registerFunction("current_user", new NoArgSQLFunction("CURRENT_USER",
                   StandardBasicTypes.STRING, false));
               registerFunction("session_user", new NoArgSQLFunction("SESSION_USER",
                   StandardBasicTypes.STRING, false));
               registerFunction("current isolation", new NoArgSQLFunction(
                   "CURRENT ISOLATION", StandardBasicTypes.STRING, false));
               registerFunction("current_role", new NoArgSQLFunction("CURRENT_ROLE",
                   StandardBasicTypes.STRING, false));
               registerFunction("current schema", new NoArgSQLFunction("CURRENT SCHEMA",
                   StandardBasicTypes.STRING, false));
               registerFunction("current sqlid", new NoArgSQLFunction("CURRENT SQLID",
                   StandardBasicTypes.STRING, false));
               registerFunction("xmlexists", new StandardSQLFunction("XMLEXISTS",
                   StandardBasicTypes.NUMERIC_BOOLEAN));
               registerFunction("xmlparse", new StandardSQLFunction("XMLPARSE",
                   StandardBasicTypes.TEXT));
               registerFunction("xmlquery", new StandardSQLFunction("XMLQUERY",
                   StandardBasicTypes.STRING));
               registerFunction("xmlserialize", new StandardSQLFunction("XMLSERIALIZE",
                   StandardBasicTypes.STRING));
               registerFunction("get_current_connection", new NoArgSQLFunction(
                   "GET_CURRENT_CONNECTION", StandardBasicTypes.BINARY, true));
               registerFunction("identity_val_local", new NoArgSQLFunction(
                   "IDENTITY_VAL_LOCAL", StandardBasicTypes.BINARY, true));
}
 
Example #27
Source File: GemFireXDDialect.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public GemFireXDDialect() {
		super();
	        LOG.info("GemFireXDDialect for Hibernate 3 initialized.");
	              
/*		registerFunction("trim", new AnsiTrimFunction());
		registerFunction("concat", new DerbyConcatFunction());*/

                registerFunction("value", new StandardSQLFunction("coalesce"));
                registerFunction("nvl", new NvlFunction());
                registerFunction("groups", new StandardSQLFunction("GROUPS",
                    Hibernate.STRING));
                registerFunction("dsid", new StandardSQLFunction("DSID", Hibernate.STRING));
                registerFunction("groupsintersection", new StandardSQLFunction(
                    "GROUPSINTERSECTION", Hibernate.STRING));
                registerFunction("groupsintersect", new StandardSQLFunction(
                    "GROUPSINTERSECT", Hibernate.BOOLEAN));
                registerFunction("groupsunion", new StandardSQLFunction("GROUPSUNION",
                    Hibernate.STRING));
                registerFunction("longint", new StandardSQLFunction("bigint",
                    Hibernate.LONG));
                registerFunction("int", new StandardSQLFunction("integer",
                    Hibernate.INTEGER));
                registerFunction("pi", new StandardSQLFunction("pi", Hibernate.DOUBLE));
                registerFunction("random", new NoArgSQLFunction("random", Hibernate.DOUBLE));
                registerFunction("rand", new StandardSQLFunction("rand", Hibernate.DOUBLE));// override
                registerFunction("sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE));
                registerFunction("cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE));
                registerFunction("tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE));
                registerFunction("user", new NoArgSQLFunction("USER", Hibernate.STRING,
                    false));
                registerFunction("current_user", new NoArgSQLFunction("CURRENT_USER",
                    Hibernate.STRING, false));
                registerFunction("session_user", new NoArgSQLFunction("SESSION_USER",
                    Hibernate.STRING, false));
                registerFunction("current isolation", new NoArgSQLFunction(
                    "CURRENT ISOLATION", Hibernate.STRING, false));
                registerFunction("current_role", new NoArgSQLFunction("CURRENT_ROLE",
                    Hibernate.STRING, false));
                registerFunction("current schema", new NoArgSQLFunction("CURRENT SCHEMA",
                    Hibernate.STRING, false));
                registerFunction("current sqlid", new NoArgSQLFunction("CURRENT SQLID",
                    Hibernate.STRING, false));
                registerFunction("xmlexists", new StandardSQLFunction("XMLEXISTS",
                    Hibernate.BOOLEAN));
                registerFunction("xmlparse", new StandardSQLFunction("XMLPARSE",
                    Hibernate.TEXT));
                registerFunction("xmlquery", new StandardSQLFunction("XMLQUERY",
                    Hibernate.STRING));
                registerFunction("xmlserialize", new StandardSQLFunction("XMLSERIALIZE",
                    Hibernate.STRING));
                registerFunction("get_current_connection", new NoArgSQLFunction(
                    "GET_CURRENT_CONNECTION", Hibernate.BINARY, true));
                registerFunction("identity_val_local", new NoArgSQLFunction(
                    "IDENTITY_VAL_LOCAL", Hibernate.BINARY, true));
	}
 
Example #28
Source File: CustomH2Dialect.java    From KOMORAN with Apache License 2.0 4 votes vote down vote up
public CustomH2Dialect() {
    super();
    this.registerFunction("GROUP_CONCAT", new StandardSQLFunction("group_concat", StringType.INSTANCE));
    this.registerFunction("CONCAT", new StandardSQLFunction("concat", StringType.INSTANCE));
    logger.debug("CustomFunctions have been registered");
}
 
Example #29
Source File: FirebirdDialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public FirebirdDialect() {
	super();
	registerFunction( "replace", new StandardSQLFunction( "replace", StandardBasicTypes.STRING ) );
}
 
Example #30
Source File: Oracle8iDialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
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) );
}