类org.hibernate.type.StandardBasicTypes源码实例Demo

下面列出了怎么用org.hibernate.type.StandardBasicTypes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: Teradata14Dialect.java
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 );
}
 
源代码2 项目: lams   文件: InterbaseDialect.java
/**
 * 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 );
}
 
源代码3 项目: lams   文件: SQLServerDialect.java
/**
 * 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 );
}
 
源代码4 项目: lams   文件: PostgresPlusDialect.java
/**
 * 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 ) );
}
 
源代码5 项目: lams   文件: SQLServer2005Dialect.java
/**
 * 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 ) );
}
 
@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");
	}

}
 
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;
	}
 
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 );
}
 
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 );
}
 
源代码10 项目: oim-fx   文件: SQLiteDialect.java
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));
}
 
源代码11 项目: dhis2-core   文件: DhisPostgresDialect.java
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 ) );
}
 
源代码12 项目: lams   文件: CollectionPropertyMapping.java
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);
	}
}
 
@Override
protected void additionalMetadata(MetadataBuilder metadataBuilder) {
    metadataBuilder.applySqlFunction(
        "group_concat",
        new StandardSQLFunction("group_concat", StandardBasicTypes.STRING)
    );
}
 
源代码14 项目: lams   文件: Ingres9Dialect.java
/**
 * Constructs a Ingres9Dialect
 */
public Ingres9Dialect() {
	super();
	registerDateTimeFunctions();
	registerDateTimeColumnTypes();
	registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(", "||", ")" ) );
}
 
源代码15 项目: lams   文件: Ingres9Dialect.java
/**
 * 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 ) );
}
 
@Override
public void contribute(MetadataBuilder metadataBuilder) {
    metadataBuilder.applySqlFunction(
            "date_trunc",
            new SQLFunctionTemplate(
                    StandardBasicTypes.TIMESTAMP,
                    "date_trunc('day', (?1 AT TIME ZONE 'UTC'))"
            )
    );
}
 
源代码17 项目: webdsl   文件: SQLiteDialect.java
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));
}
 
@Override
public void contribute(MetadataBuilder metadataBuilder) {
    metadataBuilder.applySqlFunction(
            "date_trunc",
            new SQLFunctionTemplate(
                    StandardBasicTypes.TIMESTAMP,
                    "date_trunc('day', (?1 AT TIME ZONE ?2))"
            )
    );
}
 
public CustomMySQLDialect() {
    super();

    registerFunction(
            "group_concat",
            new StandardSQLFunction("group_concat", StandardBasicTypes.STRING)
    );
}
 
源代码20 项目: lams   文件: InformixDialect.java
/**
 * 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 );
}
 
源代码21 项目: lams   文件: TimesTenDialect.java
/**
 * 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" ) );
}
 
源代码22 项目: lams   文件: MariaDB10Dialect.java
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 ) );
}
 
源代码23 项目: lams   文件: PostgreSQL94Dialect.java
/**
 * 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) );
}
 
源代码24 项目: lams   文件: BinaryArithmeticOperatorNode.java
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;
}
 
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"));
}
 
源代码26 项目: scheduling   文件: SchedulerDBManager.java
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]));
    });
}
 
public Type[] getPropertyTypes() {
	return new Type[]{ StandardBasicTypes.BIG_DECIMAL, StandardBasicTypes.CURRENCY };
}
 
源代码28 项目: butterfly   文件: SQLiteDialect.java
public SQLiteDialect() {
    registerColumnType(Types.BIT, "boolean");
    registerColumnType(Types.TINYINT, "tinyint");
    registerColumnType(Types.SMALLINT, "smallint");
    registerColumnType(Types.INTEGER, "integer");
    registerColumnType(Types.BIGINT, "bigint");
    registerColumnType(Types.FLOAT, "float");
    registerColumnType(Types.REAL, "real");
    registerColumnType(Types.DOUBLE, "double");
    registerColumnType(Types.NUMERIC, "numeric($p, $s)");
    registerColumnType(Types.DECIMAL, "decimal");
    registerColumnType(Types.CHAR, "char");
    registerColumnType(Types.VARCHAR, "varchar($l)");
    registerColumnType(Types.LONGVARCHAR, "longvarchar");
    registerColumnType(Types.DATE, "date");
    registerColumnType(Types.TIME, "time");
    registerColumnType(Types.TIMESTAMP, "datetime");
    registerColumnType(Types.BINARY, "blob");
    registerColumnType(Types.VARBINARY, "blob");
    registerColumnType(Types.LONGVARBINARY, "blob");
    registerColumnType(Types.BLOB, "blob");
    registerColumnType(Types.CLOB, "clob");
    registerColumnType(Types.BOOLEAN, "boolean");

    //registerFunction( "abs", new StandardSQLFunction("abs") );
    registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") );
    //registerFunction( "length", new StandardSQLFunction("length", StandardBasicTypes.LONG) );
    //registerFunction( "lower", new StandardSQLFunction("lower") );
    registerFunction( "mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2" ) );
    registerFunction( "quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING) );
    registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER) );
    registerFunction( "round", new StandardSQLFunction("round") );
    registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
    registerFunction( "substring", new SQLFunctionTemplate( StandardBasicTypes.STRING, "substr(?1, ?2, ?3)" ) );
    registerFunction( "trim", new AbstractAnsiTrimEmulationFunction() {
        protected SQLFunction resolveBothSpaceTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)");
        }

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

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

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

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

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

        protected SQLFunction resolveTrailingTrimFunction() {
            return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)");
        }
    } );
    //registerFunction( "upper", new StandardSQLFunction("upper") );
}
 
源代码29 项目: lams   文件: SizeExpression.java
@Override
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	return new TypedValue[] { new TypedValue( StandardBasicTypes.INTEGER, size ) };
}
 
源代码30 项目: lams   文件: UnionSubclassEntityPersister.java
public Type getDiscriminatorType() {
	return StandardBasicTypes.INTEGER;
}
 
 类所在包
 同包方法