Java Code Examples for org.hibernate.type.StandardBasicTypes#BIG_DECIMAL

The following examples show how to use org.hibernate.type.StandardBasicTypes#BIG_DECIMAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteGridTypeMapper.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 6 votes vote down vote up
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;
	}
 
Example 2
Source File: LiteralNode.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public Type getDataType() {
	if ( getExpectedType() != null ) {
		return getExpectedType();
	}

	switch ( getType() ) {
		case NUM_INT:
			return StandardBasicTypes.INTEGER;
		case NUM_FLOAT:
			return StandardBasicTypes.FLOAT;
		case NUM_LONG:
			return StandardBasicTypes.LONG;
		case NUM_DOUBLE:
			return StandardBasicTypes.DOUBLE;
		case NUM_BIG_INTEGER:
			return StandardBasicTypes.BIG_INTEGER;
		case NUM_BIG_DECIMAL:
			return StandardBasicTypes.BIG_DECIMAL;
		case QUOTED_STRING:
			return StandardBasicTypes.STRING;
		case TRUE:
		case FALSE:
			return StandardBasicTypes.BOOLEAN;
		default:
			return null;
	}
}
 
Example 3
Source File: MonetaryAmountUserType.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Type[] getPropertyTypes() {
	return new Type[]{ StandardBasicTypes.BIG_DECIMAL, StandardBasicTypes.CURRENCY };
}
 
Example 4
Source File: StandardAnsiSqlAggregationFunctions.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type getReturnType(Type firstArgumentType, Mapping mapping) {
	final int jdbcType = determineJdbcTypeCode( firstArgumentType, mapping );

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

	// finally use the jdbcType if == on Hibernate types did not find a match.
	//
	//	IMPL NOTE : we do not match on Types.NUMERIC because it could be either, so we fall-through to the
	// 		first argument type
	if ( jdbcType == Types.FLOAT
			|| jdbcType == Types.DOUBLE
			|| jdbcType == Types.DECIMAL
			|| jdbcType == Types.REAL) {
		return StandardBasicTypes.DOUBLE;
	}
	else if ( jdbcType == Types.BIGINT
			|| jdbcType == Types.INTEGER
			|| jdbcType == Types.SMALLINT
			|| jdbcType == Types.TINYINT ) {
		return StandardBasicTypes.LONG;
	}

	// as a last resort, return the type of the first argument
	return firstArgumentType;
}
 
Example 5
Source File: BinaryArithmeticOperatorNode.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
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.
	final Node lhs = getLeftHandOperand();
	final Node rhs = getRightHandOperand();

	final Type lhType = ( lhs instanceof SqlNode ) ? ( (SqlNode) lhs ).getDataType() : null;
	final 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
				// BLIND GUESS!
				return StandardBasicTypes.DOUBLE;
			}
			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 == StandardBasicTypes.DOUBLE || rhType == StandardBasicTypes.DOUBLE ) {
					return StandardBasicTypes.DOUBLE;
				}
				if ( lhType == StandardBasicTypes.FLOAT || rhType == StandardBasicTypes.FLOAT ) {
					return StandardBasicTypes.FLOAT;
				}
				if ( lhType == StandardBasicTypes.BIG_DECIMAL || rhType == StandardBasicTypes.BIG_DECIMAL ) {
					return StandardBasicTypes.BIG_DECIMAL;
				}
				if ( lhType == StandardBasicTypes.BIG_INTEGER || rhType == StandardBasicTypes.BIG_INTEGER ) {
					return StandardBasicTypes.BIG_INTEGER;
				}
				if ( lhType == StandardBasicTypes.LONG || rhType == StandardBasicTypes.LONG ) {
					return StandardBasicTypes.LONG;
				}
				if ( lhType == StandardBasicTypes.INTEGER || rhType == StandardBasicTypes.INTEGER ) {
					return StandardBasicTypes.INTEGER;
				}
				return lhType;
			}
		}
	}
}
 
Example 6
Source File: AbstractBigDecimalColumnMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public final BigDecimalType getHibernateType() {
	return StandardBasicTypes.BIG_DECIMAL;
}