FileDocCategorySizeDatePackage
NumericTrueFalseType.javaAPI DocHibernate 3.2.51268Thu Mar 29 08:25:48 BST 2007org.hibernate.test.where

NumericTrueFalseType

public class NumericTrueFalseType extends org.hibernate.type.BooleanType
Maps int db values to boolean java values. Zero is considered false; any non-zero value is considered true.
author
Steve Ebersole

Fields Summary
Constructors Summary
Methods Summary
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)

		int value = rs.getInt( name );
		if ( rs.wasNull() ) {
			return getDefaultValue();
		}
		else if ( value == 0 ) {
			return Boolean.FALSE;
		}
		else {
			return Boolean.TRUE;
		}
	
public java.lang.StringgetName()

		return "numeric_boolean";
	
public java.lang.StringobjectToSQLString(java.lang.Object value, org.hibernate.dialect.Dialect dialect)

		return ( ( Boolean ) value ).booleanValue() ? "1" : "0";
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)

		if ( value == null ) {
			st.setNull( index, Types.INTEGER );
		}
		else {
			boolean bool = ( ( Boolean ) value ).booleanValue();
			st.setInt( index, bool ? 1 : 0 );
		}
	
public intsqlType()

		return Types.INTEGER;