org.hibernate.Hibernate#DOUBLE源码实例Demo

下面列出了org.hibernate.Hibernate#DOUBLE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cacheonix-core   文件: LiteralNode.java
public Type getDataType() {
	switch ( getType() ) {
		case NUM_INT:
			return Hibernate.INTEGER;
		case NUM_FLOAT:
			return Hibernate.FLOAT;
		case NUM_LONG:
			return Hibernate.LONG;
		case NUM_DOUBLE:
			return Hibernate.DOUBLE;
		case QUOTED_STRING:
			return Hibernate.STRING;
		case TRUE:
		case FALSE:
			return Hibernate.BOOLEAN;
		default:
			return null;
	}
}
 
源代码2 项目: cacheonix-core   文件: Dialect.java
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()" );
	return Hibernate.DOUBLE;
}
 
源代码3 项目: cacheonix-core   文件: Dialect.java
public Type getReturnType(Type columnType, Mapping mapping) {
	//pre H3.2 behavior: super.getReturnType(ct, m);
	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 sum()" );
	int sqlType = sqlTypes[0];

	// First allow the actual type to control the return value. (the actual underlying sqltype could actually be different)
	if ( columnType == Hibernate.BIG_INTEGER ) {
		return Hibernate.BIG_INTEGER;
	}
	else if ( columnType == Hibernate.BIG_DECIMAL ) {
		return Hibernate.BIG_DECIMAL;
	}
	else if ( columnType == Hibernate.LONG || columnType == Hibernate.SHORT || columnType == Hibernate.INTEGER) {
		return Hibernate.LONG;
	}
	else if ( columnType == Hibernate.FLOAT || columnType == Hibernate.DOUBLE) {
		return Hibernate.DOUBLE;
	}

	// finally use the sqltype if == on Hibernate types did not find a match.
	if ( sqlType == Types.NUMERIC ) {
		return columnType; //because numeric can be anything
	}
	else if ( sqlType == Types.FLOAT || sqlType == Types.DOUBLE || sqlType == Types.DECIMAL || sqlType == Types.REAL) {
		return Hibernate.DOUBLE;
	}
	else if ( sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.SMALLINT || sqlType == Types.TINYINT ) {
		return Hibernate.LONG;
	}
	else {
		return columnType;
	}
}
 
private Type resolveDataType() {
	// TODO : we may also want to check that the types here map to exactly one column/JDBC-type
	//      can't think of a situation where arithmetic expression between multi-column mappings
	//      makes any sense.
	Node lhs = getLeftHandOperand();
	Node rhs = getRightHandOperand();
	Type lhType = ( lhs instanceof SqlNode ) ? ( ( SqlNode ) lhs ).getDataType() : null;
	Type rhType = ( rhs instanceof SqlNode ) ? ( ( SqlNode ) rhs ).getDataType() : null;
	if ( isDateTimeType( lhType ) || isDateTimeType( rhType ) ) {
		return resolveDateTimeArithmeticResultType( lhType, rhType );
	}
	else {
		if ( lhType == null ) {
			if ( rhType == null ) {
				// we do not know either type
				return Hibernate.DOUBLE; //BLIND GUESS!
			}
			else {
				// we know only the rhs-hand type, so use that
				return rhType;
			}
		}
		else {
			if ( rhType == null ) {
				// we know only the lhs-hand type, so use that
				return lhType;
			}
			else {
				if ( lhType==Hibernate.DOUBLE || rhType==Hibernate.DOUBLE ) return Hibernate.DOUBLE;
				if ( lhType==Hibernate.FLOAT || rhType==Hibernate.FLOAT ) return Hibernate.FLOAT;
				if ( lhType==Hibernate.BIG_DECIMAL || rhType==Hibernate.BIG_DECIMAL ) return Hibernate.BIG_DECIMAL;
				if ( lhType==Hibernate.BIG_INTEGER || rhType==Hibernate.BIG_INTEGER ) return Hibernate.BIG_INTEGER;
				if ( lhType==Hibernate.LONG || rhType==Hibernate.LONG ) return Hibernate.LONG;
				if ( lhType==Hibernate.INTEGER || rhType==Hibernate.INTEGER ) return Hibernate.INTEGER;
				return lhType;
			}
		}
	}
}
 
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 Hibernate.DOUBLE;
		}
	}
	return null;
}
 
源代码6 项目: cacheonix-core   文件: AvgProjection.java
public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
	return new Type[] { Hibernate.DOUBLE };
}