當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。