当前位置: 首页>>代码示例>>Java>>正文


Java Type.sqlTypes方法代码示例

本文整理汇总了Java中org.hibernate.type.Type.sqlTypes方法的典型用法代码示例。如果您正苦于以下问题:Java Type.sqlTypes方法的具体用法?Java Type.sqlTypes怎么用?Java Type.sqlTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.type.Type的用法示例。


在下文中一共展示了Type.sqlTypes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getReturnType

import org.hibernate.type.Type; //导入方法依赖的package包/类
@Override
public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
	int[] sqlTypes;
	try {
		sqlTypes = columnType.sqlTypes( mapping );
	}
	catch ( MappingException me ) {
		throw new QueryException( me );
	}

	if ( sqlTypes.length != 1 ) {
		throw new QueryException( "multi-column type in avg()" );
	}

	final int sqlType = sqlTypes[0];
	if ( sqlType == Types.INTEGER || sqlType == Types.BIGINT || sqlType == Types.TINYINT ) {
		return StandardBasicTypes.FLOAT;
	}
	else {
		return columnType;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ClassicAvgFunction.java

示例2: toSqlString

import org.hibernate.type.Type; //导入方法依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
	final String[] columns = criteriaQuery.findColumns( propertyName, criteria );
	final Type type = criteriaQuery.getTypeUsingProjection( criteria, propertyName );
	final StringBuilder fragment = new StringBuilder();

	if ( columns.length > 1 ) {
		fragment.append( '(' );
	}
	final SessionFactoryImplementor factory = criteriaQuery.getFactory();
	final int[] sqlTypes = type.sqlTypes( factory );
	for ( int i = 0; i < columns.length; i++ ) {
		final boolean lower = ignoreCase && (sqlTypes[i] == Types.VARCHAR || sqlTypes[i] == Types.CHAR);
		if ( lower ) {
			fragment.append( factory.getDialect().getLowercaseFunction() ).append( '(' );
		}
		fragment.append( columns[i] );
		if ( lower ) {
			fragment.append( ')' );
		}

		fragment.append( getOp() ).append( "?" );
		if ( i < columns.length - 1 ) {
			fragment.append( " and " );
		}
	}
	if ( columns.length > 1 ) {
		fragment.append( ')' );
	}
	return fragment.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:SimpleExpression.java

示例3: determineJdbcTypeCode

import org.hibernate.type.Type; //导入方法依赖的package包/类
protected final int determineJdbcTypeCode(Type firstArgumentType, SessionFactoryImplementor factory) throws QueryException {
	try {
		final int[] jdbcTypeCodes = firstArgumentType.sqlTypes( factory );
		if ( jdbcTypeCodes.length != 1 ) {
			throw new QueryException( "multiple-column type in avg()" );
		}
		return jdbcTypeCodes[0];
	}
	catch ( MappingException me ) {
		throw new QueryException( me );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:StandardAnsiSqlAggregationFunctions.java

示例4: areCompatible

import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
 * Determine whether the two types are "assignment compatible".
 *
 * @param target The type defined in the into-clause.
 * @param source The type defined in the select clause.
 * @return True if they are assignment compatible.
 */
private boolean areCompatible(Type target, Type source) {
	if ( target.equals( source ) ) {
		// if the types report logical equivalence, return true...
		return true;
	}

	// otherwise, doAfterTransactionCompletion a "deep equivalence" check...

	if ( !target.getReturnedClass().isAssignableFrom( source.getReturnedClass() ) ) {
		return false;
	}

	int[] targetDatatypes = target.sqlTypes( getSessionFactoryHelper().getFactory() );
	int[] sourceDatatypes = source.sqlTypes( getSessionFactoryHelper().getFactory() );

	if ( targetDatatypes.length != sourceDatatypes.length ) {
		return false;
	}

	for ( int i = 0; i < targetDatatypes.length; i++ ) {
		if ( !areSqlTypesCompatible( targetDatatypes[i], sourceDatatypes[i] ) ) {
			return false;
		}
	}

	return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:IntoClause.java

示例5: toSqlString

import org.hibernate.type.Type; //导入方法依赖的package包/类
/**
 * Render the SQL fragment
 *
 * @param criteria The criteria
 * @param criteriaQuery The overall query
 *
 * @return The ORDER BY fragment for this ordering
 */
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
	final String[] columns = criteriaQuery.getColumnsUsingProjection( criteria, propertyName );
	final Type type = criteriaQuery.getTypeUsingProjection( criteria, propertyName );
	final SessionFactoryImplementor factory = criteriaQuery.getFactory();
	final int[] sqlTypes = type.sqlTypes( factory );

	final StringBuilder fragment = new StringBuilder();
	for ( int i=0; i<columns.length; i++ ) {
		final StringBuilder expression = new StringBuilder();
		boolean lower = false;
		if ( ignoreCase ) {
			final int sqlType = sqlTypes[i];
			lower = sqlType == Types.VARCHAR
					|| sqlType == Types.CHAR
					|| sqlType == Types.LONGVARCHAR;
		}
		
		if ( lower ) {
			expression.append( factory.getDialect().getLowercaseFunction() )
					.append( '(' );
		}
		expression.append( columns[i] );
		if ( lower ) {
			expression.append( ')' );
		}

		fragment.append(
				factory.getDialect().renderOrderByElement(
						expression.toString(),
						null,
						ascending ? "asc" : "desc",
						nullPrecedence != null ? nullPrecedence : factory.getSettings().getDefaultNullPrecedence()
				)
		);
		if ( i < columns.length-1 ) {
			fragment.append( ", " );
		}
	}

	return fragment.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:Order.java


注:本文中的org.hibernate.type.Type.sqlTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。