FileDocCategorySizeDatePackage
ClassicAvgFunction.javaAPI DocHibernate 3.2.51047Mon May 08 15:59:20 BST 2006org.hibernate.dialect.function

ClassicAvgFunction

public class ClassicAvgFunction extends StandardSQLFunction
Classic AVG sqlfunction that return types as it was done in Hibernate 3.1
author
Max Rydahl Andersen

Fields Summary
Constructors Summary
public ClassicAvgFunction()

		super( "avg" );
	
Methods Summary
public org.hibernate.type.TypegetReturnType(org.hibernate.type.Type columnType, org.hibernate.engine.Mapping mapping)

		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()" );
		int sqlType = sqlTypes[0];
		if ( sqlType == Types.INTEGER || sqlType == Types.BIGINT || sqlType == Types.TINYINT ) {
			return Hibernate.FLOAT;
		}
		else {
			return columnType;
		}