org.hibernate.type.StandardBasicTypes Java Examples

The following examples show how to use org.hibernate.type.StandardBasicTypes. 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: IgniteGridTypeMapper.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 6 votes vote down vote up
public GridType overrideType(Type type) {

		if ( type == StandardBasicTypes.BIG_DECIMAL ) {
			return IgniteBigDecimalType.INSTANCE;
		}

		if ( type == StandardBasicTypes.BIG_INTEGER ) {
			return IgniteBigIntegerType.INSTANCE;
		}

		if ( type == StandardBasicTypes.CALENDAR ) {
			return IgniteCalendarType.INSTANCE;
		}

		if ( type == StandardBasicTypes.CALENDAR_DATE ) {
			return IgniteCalendarType.INSTANCE;
		}

		return null;
	}
 
Example #2
Source File: FunctionTemplateRegistrator.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void register(Dialect dialect) {
	logger.debug("IN");
	try {
		if (function.getCode() != null || !function.getCode().equals("")) {
			dialect.registerFunction(function.getName(),
					new SQLFunctionTemplate((Type) StandardBasicTypes.class.getField(function.getType()).get(null), function.getCode()));
		}

	} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
		logger.error("Error while registering function", e);
		throw new SpagoBIEngineRuntimeException("Error while registering function", e);
	} finally {
		logger.debug("OUT");
	}

}
 
Example #3
Source File: SQLServer2005Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a SQLServer2005Dialect
 */
public SQLServer2005Dialect() {
	// HHH-3965 fix
	// As per http://www.sql-server-helper.com/faq/sql-server-2005-varchar-max-p01.aspx
	// use varchar(max) and varbinary(max) instead of TEXT and IMAGE types
	registerColumnType( Types.BLOB, "varbinary(MAX)" );
	registerColumnType( Types.VARBINARY, "varbinary(MAX)" );
	registerColumnType( Types.VARBINARY, MAX_LENGTH, "varbinary($l)" );
	registerColumnType( Types.LONGVARBINARY, "varbinary(MAX)" );

	registerColumnType( Types.CLOB, "varchar(MAX)" );
	registerColumnType( Types.LONGVARCHAR, "varchar(MAX)" );
	registerColumnType( Types.VARCHAR, "varchar(MAX)" );
	registerColumnType( Types.VARCHAR, MAX_LENGTH, "varchar($l)" );

	registerColumnType( Types.BIGINT, "bigint" );
	registerColumnType( Types.BIT, "bit" );
	
	// HHH-8435 fix
	registerColumnType( Types.NCLOB, "nvarchar(MAX)" );

	registerFunction( "row_number", new NoArgSQLFunction( "row_number", StandardBasicTypes.INTEGER, true ) );
}
 
Example #4
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 #5
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 #6
Source File: Teradata14Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public Teradata14Dialect() {
	super();
	//registerColumnType data types
	registerColumnType( Types.BIGINT, "BIGINT" );
	registerColumnType( Types.BINARY, "VARBYTE(100)" );
	registerColumnType( Types.LONGVARBINARY, "VARBYTE(32000)" );
	registerColumnType( Types.LONGVARCHAR, "VARCHAR(32000)" );

	getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
	getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );

	registerFunction( "current_time", new SQLFunctionTemplate( StandardBasicTypes.TIME, "current_time" ) );
	registerFunction( "current_date", new SQLFunctionTemplate( StandardBasicTypes.DATE, "current_date" ) );

	TeraIndexExporter =  new TeradataIndexExporter( this );
}
 
Example #7
Source File: InterbaseDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a InterbaseDialect
 */
public InterbaseDialect() {
	super();
	registerColumnType( Types.BIT, "smallint" );
	registerColumnType( Types.BIGINT, "numeric(18,0)" );
	registerColumnType( Types.SMALLINT, "smallint" );
	registerColumnType( Types.TINYINT, "smallint" );
	registerColumnType( Types.INTEGER, "integer" );
	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, "blob" );
	registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
	registerColumnType( Types.BLOB, "blob" );
	registerColumnType( Types.CLOB, "blob sub_type 1" );
	registerColumnType( Types.BOOLEAN, "smallint" );
	
	registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(","||",")" ) );
	registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE, false ) );

	getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
 
Example #8
Source File: SchedulerDBManager.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
public Map<JobId, String> getJobsToRemove(final long time) {
    return executeReadOnlyTransaction(session -> {
        Query query = session.createSQLQuery("select ID, OWNER from JOB_DATA where " +
                                             "SCHEDULED_TIME_FOR_REMOVAL <> 0 and " +
                                             "SCHEDULED_TIME_FOR_REMOVAL < :timeLimit")
                             .addScalar("ID", StandardBasicTypes.LONG)
                             .addScalar("OWNER", StandardBasicTypes.STRING)
                             .setParameter("timeLimit", time);

        return ((List<Object[]>) query.list()).stream()
                                              .collect(Collectors.toMap(pair -> JobIdImpl.makeJobId(((Long) pair[0]).toString()),
                                                                        pair -> (String) pair[1]));
    });
}
 
Example #9
Source File: MonetaryAmountUserType.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void nullSafeSet(
		PreparedStatement st, Object value, int index,
		SharedSessionContractImplementor session
) throws HibernateException, SQLException {
	MonetaryAmount ma = (MonetaryAmount) value;
	BigDecimal amt = ma == null ? null : ma.getAmount();
	Currency cur = ma == null ? null : ma.getCurrency();
	StandardBasicTypes.BIG_DECIMAL.nullSafeSet( st, amt, index, session );
	StandardBasicTypes.CURRENCY.nullSafeSet( st, cur, index + 1, session );
}
 
Example #10
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 #11
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 #12
Source File: CollectionPropertyMapping.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public Type toType(String propertyName) throws QueryException {
	if ( propertyName.equals(CollectionPropertyNames.COLLECTION_ELEMENTS) ) {
		return memberPersister.getElementType();
	}
	else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_INDICES) ) {
		if ( !memberPersister.hasIndex() ) {
			throw new QueryException("unindexed collection before indices()");
		}
		return memberPersister.getIndexType();
	}
	else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_SIZE) ) {
		return StandardBasicTypes.INTEGER;
	}
	else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MAX_INDEX) ) {
		return memberPersister.getIndexType();
	}
	else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MIN_INDEX) ) {
		return memberPersister.getIndexType();
	}
	else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MAX_ELEMENT) ) {
		return memberPersister.getElementType();
	}
	else if ( propertyName.equals(CollectionPropertyNames.COLLECTION_MIN_ELEMENT) ) {
		return memberPersister.getElementType();
	}
	else {
		//return memberPersister.getPropertyType(propertyName);
		throw new QueryException("illegal syntax near collection: " + propertyName);
	}
}
 
Example #13
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 #14
Source File: Ingres9Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Ingres9Dialect
 */
public Ingres9Dialect() {
	super();
	registerDateTimeFunctions();
	registerDateTimeColumnTypes();
	registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
}
 
Example #15
Source File: Ingres9Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 ) );
}
 
Example #16
Source File: DateTruncUtcFunctionTest.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(
            "date_trunc",
            new SQLFunctionTemplate(
                    StandardBasicTypes.TIMESTAMP,
                    "date_trunc('day', (?1 AT TIME ZONE 'UTC'))"
            )
    );
}
 
Example #17
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 #18
Source File: DateTruncTimeZoneFunctionTest.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(
            "date_trunc",
            new SQLFunctionTemplate(
                    StandardBasicTypes.TIMESTAMP,
                    "date_trunc('day', (?1 AT TIME ZONE ?2))"
            )
    );
}
 
Example #19
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 #20
Source File: InformixDialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates new <code>InformixDialect</code> instance. Sets up the JDBC /
 * Informix type mappings.
 */
public InformixDialect() {
	super();

	registerColumnType( Types.BIGINT, "int8" );
	registerColumnType( Types.BINARY, "byte" );
	// Informix doesn't have a bit type
	registerColumnType( Types.BIT, "smallint" );
	registerColumnType( Types.CHAR, "char($l)" );
	registerColumnType( Types.DATE, "date" );
	registerColumnType( Types.DECIMAL, "decimal" );
	registerColumnType( Types.DOUBLE, "float" );
	registerColumnType( Types.FLOAT, "smallfloat" );
	registerColumnType( Types.INTEGER, "integer" );
	// or BYTE
	registerColumnType( Types.LONGVARBINARY, "blob" );
	// or TEXT?
	registerColumnType( Types.LONGVARCHAR, "clob" );
	// or MONEY
	registerColumnType( Types.NUMERIC, "decimal" );
	registerColumnType( Types.REAL, "smallfloat" );
	registerColumnType( Types.SMALLINT, "smallint" );
	registerColumnType( Types.TIMESTAMP, "datetime year to fraction(5)" );
	registerColumnType( Types.TIME, "datetime hour to second" );
	registerColumnType( Types.TINYINT, "smallint" );
	registerColumnType( Types.VARBINARY, "byte" );
	registerColumnType( Types.VARCHAR, "varchar($l)" );
	registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
	registerColumnType( Types.VARCHAR, 32739, "lvarchar($l)" );

	registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
	registerFunction( "substring", new SQLFunctionTemplate(StandardBasicTypes.STRING, "substring(?1 FROM ?2 FOR ?3)"));
	registerFunction( "substr", new SQLFunctionTemplate( StandardBasicTypes.STRING, "substr(?1, ?2, ?3)"));
	registerFunction( "coalesce", new NvlFunction());
	registerFunction( "nvl", new NvlFunction());
	registerFunction( "current_timestamp", new NoArgSQLFunction( "current", StandardBasicTypes.TIMESTAMP, false ) );
	registerFunction( "current_date", new NoArgSQLFunction( "today", StandardBasicTypes.DATE, false ) );

	uniqueDelegate = new InformixUniqueDelegate( this );
}
 
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: 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 #23
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 #24
Source File: BinaryArithmeticOperatorNode.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private Type resolveDateTimeArithmeticResultType(Type lhType, Type rhType) {
	// here, we work under the following assumptions:
	//      ------------ valid cases --------------------------------------
	//      1) datetime + {something other than datetime} : always results
	//              in a datetime ( db will catch invalid conversions )
	//      2) datetime - datetime : always results in a DOUBLE
	//      3) datetime - {something other than datetime} : always results
	//              in a datetime ( db will catch invalid conversions )
	//      ------------ invalid cases ------------------------------------
	//      4) datetime + datetime
	//      5) {something other than datetime} - datetime
	//      6) datetime * {any type}
	//      7) datetime / {any type}
	//      8) {any type} / datetime
	// doing so allows us to properly handle parameters as either the left
	// or right side here in the majority of cases
	boolean lhsIsDateTime = isDateTimeType( lhType );
	boolean rhsIsDateTime = isDateTimeType( rhType );

	// handle the (assumed) valid cases:
	// #1 - the only valid datetime addition synatx is one or the other is a datetime (but not both)
	if ( getType() == HqlSqlTokenTypes.PLUS ) {
		// one or the other needs to be a datetime for us to get into this method in the first place...
		return lhsIsDateTime ? lhType : rhType;
	}
	else if ( getType() == HqlSqlTokenTypes.MINUS ) {
		// #3 - note that this is also true of "datetime - :param"...
		if ( lhsIsDateTime && !rhsIsDateTime ) {
			return lhType;
		}
		// #2
		if ( lhsIsDateTime && rhsIsDateTime ) {
			return StandardBasicTypes.DOUBLE;
		}
	}
	return null;
}
 
Example #25
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 #26
Source File: MonetaryAmountUserType.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
		throws HibernateException, SQLException {
	BigDecimal amt = StandardBasicTypes.BIG_DECIMAL.nullSafeGet( rs, names[0], session);
	Currency cur = StandardBasicTypes.CURRENCY.nullSafeGet( rs, names[1], session );
	if ( amt == null ) return null;
	return new MonetaryAmount( amt, cur );
}
 
Example #27
Source File: SizeExpression.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	return new TypedValue[] { new TypedValue( StandardBasicTypes.INTEGER, size ) };
}
 
Example #28
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 #29
Source File: AbstractScrollableResults.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public final BigDecimal getBigDecimal(int col) throws HibernateException {
	return (BigDecimal) getFinal( col, StandardBasicTypes.BIG_DECIMAL );
}
 
Example #30
Source File: Cache71Dialect.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected final void register71Functions() {
	this.registerFunction( "str", new VarArgsSQLFunction( StandardBasicTypes.STRING, "str(", ",", ")" ) );
}