Here you can find the source of getPreferredHibernateType(int sqlType, int size, int precision, int scale, boolean nullable, boolean generatedIdentifier)
public static String getPreferredHibernateType(int sqlType, int size, int precision, int scale, boolean nullable, boolean generatedIdentifier)
//package com.java2s; import java.sql.Types; import java.util.HashMap; import java.util.Map; public class Main { /** The Map containing the preferred conversion type values. */ private static final Map<Integer, String[]> PREFERRED_HIBERNATETYPE_FOR_SQLTYPE = new HashMap<Integer, String[]>(); public static String getPreferredHibernateType(int sqlType, int size, int precision, int scale, boolean nullable, boolean generatedIdentifier) { boolean returnNullable = nullable || generatedIdentifier; if ((sqlType == Types.DECIMAL || sqlType == Types.NUMERIC) && scale <= 0) { // <= if (precision == 1) { // NUMERIC(1) is a often used idiom for storing boolean thus providing it out of the box. return returnNullable ? Boolean.class.getName() : "boolean"; //$NON-NLS-1$ } else if (precision < 3) { return returnNullable ? Byte.class.getName() : "byte"; //$NON-NLS-1$ } else if (precision < 5) { return returnNullable ? Short.class.getName() : "short"; //$NON-NLS-1$ } else if (precision < 10) { return returnNullable ? Integer.class.getName() : "int"; //$NON-NLS-1$ } else if (precision < 19) { return returnNullable ? Long.class.getName() : "long"; //$NON-NLS-1$ } else { return "big_decimal"; //$NON-NLS-1$ }//from www . j a v a2s.c o m } if (sqlType == Types.CHAR && size > 1) { return "string"; //$NON-NLS-1$ } String[] result = (String[]) PREFERRED_HIBERNATETYPE_FOR_SQLTYPE.get(new Integer(sqlType)); if (result == null) { return null; } else if (returnNullable) { return result[1]; } else { return result[0]; } } }