Skip to content

Commit edc4218

Browse files
committed
HBX-1408 - Remove floating point types from types advertised to support precision & scale
1 parent 9f1fc34 commit edc4218

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

orm/src/main/java/org/hibernate/tool/internal/reveng/reader/BasicColumnProcessor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ public static void processBasicColumns(
8585
if(JdbcToHibernateTypeHelper.typeHasLength(sqlType) ) {
8686
column.setLength(size);
8787
}
88-
if(JdbcToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
88+
if(JdbcToHibernateTypeHelper.typeHasPrecision(sqlType) ) {
8989
column.setPrecision(size);
9090
}
9191
}
9292
if(intBounds(decimalDigits) ) {
93-
if(JdbcToHibernateTypeHelper.typeHasScaleAndPrecision(sqlType) ) {
93+
if(JdbcToHibernateTypeHelper.typeHasScale(sqlType) ) {
9494
column.setScale(decimalDigits);
9595
}
9696
}

orm/src/main/java/org/hibernate/tool/internal/util/JdbcToHibernateTypeHelper.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,25 @@ public static String getJDBCTypeName(int value) {
183183
* @throws SQLException
184184
*/
185185

186-
// scale and precision have numeric column
187-
public static boolean typeHasScaleAndPrecision(int sqlType) {
186+
// scale is for non floating point numeric columns
187+
public static boolean typeHasScale(int sqlType) {
188+
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC);
189+
}
190+
191+
// precision is for numeric columns
192+
public static boolean typeHasPrecision(int sqlType) {
188193
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC
189194
|| sqlType == Types.REAL || sqlType == Types.FLOAT || sqlType == Types.DOUBLE);
190195
}
196+
197+
public static boolean typeHasScaleAndPrecision(int sqlType) {
198+
return typeHasScale(sqlType) && typeHasPrecision(sqlType);
199+
}
191200

192-
// length is for string column
201+
// length is for string columns
193202
public static boolean typeHasLength(int sqlType) {
194203
return (sqlType == Types.CHAR || sqlType == Types.DATE
195204
|| sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
196205
|| sqlType == Types.VARCHAR );
197206
}
198207
}
199-

0 commit comments

Comments
 (0)