Skip to content

Commit a95da86

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

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
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

+21-13
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) {
188-
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC
189-
|| sqlType == Types.REAL || sqlType == Types.FLOAT || sqlType == Types.DOUBLE);
190-
}
191-
192-
// length is for string column
193-
public static boolean typeHasLength(int sqlType) {
194-
return (sqlType == Types.CHAR || sqlType == Types.DATE
195-
|| sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
196-
|| sqlType == Types.VARCHAR );
197-
}
198-
}
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) {
193+
return (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC
194+
|| sqlType == Types.REAL || sqlType == Types.FLOAT || sqlType == Types.DOUBLE);
195+
}
199196

197+
public static boolean typeHasScaleAndPrecision(int sqlType) {
198+
return typeHasScale(sqlType) && typeHasPrecision(sqlType);
199+
}
200+
201+
// length is for string columns
202+
public static boolean typeHasLength(int sqlType) {
203+
return (sqlType == Types.CHAR || sqlType == Types.DATE
204+
|| sqlType == Types.LONGVARCHAR || sqlType == Types.TIME || sqlType == Types.TIMESTAMP
205+
|| sqlType == Types.VARCHAR );
206+
}
207+
}

0 commit comments

Comments
 (0)