Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public static void processBasicColumns(
if(JdbcToHibernateTypeHelper.typeHasLength(sqlType) ) {
column.setLength(size);
}
if(JdbcToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
if(JdbcToHibernateTypeHelper.typeHasPrecision(sqlType) ) {
column.setPrecision(size);
}
}
if(intBounds(decimalDigits) ) {
if(JdbcToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
if(JdbcToHibernateTypeHelper.typeHasScale(sqlType) ) {
column.setScale(decimalDigits);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,25 @@ public static String getJDBCTypeName(int value) {
* @throws SQLException
*/

// scale and precision have numeric column
public static boolean typeHasScaleAndPrecision(int sqlType) {
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC
|| sqlType == Types.REAL || sqlType == Types.FLOAT || sqlType == Types.DOUBLE);
}

// length is for string column
public static boolean typeHasLength(int sqlType) {
return (sqlType == Types.CHAR || sqlType == Types.DATE
|| sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
|| sqlType == Types.VARCHAR );
}
}
// scale is for non floating point numeric columns
public static boolean typeHasScale(int sqlType) {
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC);
}

// precision is for numeric columns
public static boolean typeHasPrecision(int sqlType) {
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC
|| sqlType == Types.REAL || sqlType == Types.FLOAT || sqlType == Types.DOUBLE);
}

public static boolean typeHasScaleAndPrecision(int sqlType) {
return typeHasScale(sqlType) && typeHasPrecision(sqlType);
}

// length is for string columns
public static boolean typeHasLength(int sqlType) {
return (sqlType == Types.CHAR || sqlType == Types.DATE
|| sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
|| sqlType == Types.VARCHAR );
}
}