Skip to content

Commit fc9229e

Browse files
committed
warning cleanups in Dialects
1 parent 47f9bcf commit fc9229e

14 files changed

+910
-1367
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -60,36 +60,25 @@ public AbstractTransactSQLDialect(DialectResolutionInfo info) {
6060
protected String columnType(int sqlTypeCode) {
6161
// note that 'real' is double precision on SQL Server, single precision on Sybase
6262
// but 'float' is single precision on Sybase, double precision on SQL Server
63-
switch ( sqlTypeCode ) {
64-
case BOOLEAN:
65-
return "bit";
66-
67-
case TINYINT:
68-
//'tinyint' is an unsigned type in Sybase and
69-
//SQL Server, holding values in the range 0-255
70-
//see HHH-6779
71-
return "smallint";
72-
case INTEGER:
73-
//it's called 'int' not 'integer'
74-
return "int";
75-
76-
case DATE:
77-
case TIME:
78-
case TIMESTAMP:
79-
case TIME_WITH_TIMEZONE:
80-
case TIMESTAMP_WITH_TIMEZONE:
81-
return "datetime";
82-
83-
case BLOB:
84-
return "image";
85-
case CLOB:
86-
return "text";
87-
case NCLOB:
88-
return "ntext";
89-
90-
default:
91-
return super.columnType( sqlTypeCode );
92-
}
63+
return switch (sqlTypeCode) {
64+
case BOOLEAN -> "bit";
65+
66+
// 'tinyint' is an unsigned type in Sybase and
67+
// SQL Server, holding values in the range 0-255
68+
// see HHH-6779
69+
case TINYINT -> "smallint";
70+
71+
//it's called 'int' not 'integer'
72+
case INTEGER -> "int";
73+
74+
case DATE, TIME, TIMESTAMP, TIME_WITH_TIMEZONE, TIMESTAMP_WITH_TIMEZONE -> "datetime";
75+
76+
case BLOB -> "image";
77+
case CLOB -> "text";
78+
case NCLOB -> "ntext";
79+
80+
default -> super.columnType( sqlTypeCode );
81+
};
9382
}
9483

9584
@Override
@@ -173,20 +162,17 @@ public String trimPattern(TrimSpec specification, boolean isWhitespace) {
173162
}
174163

175164
public static String replaceLtrimRtrim(TrimSpec specification, boolean isWhitespace) {
176-
switch ( specification ) {
177-
case LEADING:
178-
return isWhitespace
179-
? "ltrim(?1)"
180-
: "substring(?1,patindex('%[^'+?2+']%',?1),len(?1+'x')-1-patindex('%[^'+?2+']%',?1)+1)";
181-
case TRAILING:
182-
return isWhitespace
183-
? "rtrim(?1)"
184-
: "substring(?1,1,len(?1+'x')-1-patindex('%[^'+?2+']%',reverse(?1))+1)";
185-
default:
186-
return isWhitespace
187-
? "ltrim(rtrim(?1))"
188-
: "substring(?1,patindex('%[^'+?2+']%',?1),len(?1+'x')-1-patindex('%[^'+?2+']%',?1)-patindex('%[^'+?2+']%',reverse(?1))+2)";
189-
}
165+
return switch (specification) {
166+
case LEADING -> isWhitespace
167+
? "ltrim(?1)"
168+
: "substring(?1,patindex('%[^'+?2+']%',?1),len(?1+'x')-1-patindex('%[^'+?2+']%',?1)+1)";
169+
case TRAILING -> isWhitespace
170+
? "rtrim(?1)"
171+
: "substring(?1,1,len(?1+'x')-1-patindex('%[^'+?2+']%',reverse(?1))+1)";
172+
default -> isWhitespace
173+
? "ltrim(rtrim(?1))"
174+
: "substring(?1,patindex('%[^'+?2+']%',?1),len(?1+'x')-1-patindex('%[^'+?2+']%',?1)-patindex('%[^'+?2+']%',reverse(?1))+2)";
175+
};
190176
}
191177

192178
@Override

0 commit comments

Comments
 (0)