41
41
import org .hibernate .LockMode ;
42
42
import org .hibernate .LockOptions ;
43
43
import org .hibernate .NotYetImplementedFor6Exception ;
44
- import org .hibernate .query .Query ;
45
44
import org .hibernate .ScrollMode ;
46
45
import org .hibernate .boot .TempTableDdlTransactionHandling ;
47
46
import org .hibernate .boot .model .TypeContributions ;
96
95
import org .hibernate .exception .spi .SQLExceptionConversionDelegate ;
97
96
import org .hibernate .exception .spi .SQLExceptionConverter ;
98
97
import org .hibernate .exception .spi .ViolatedConstraintNameExtractor ;
98
+ import org .hibernate .internal .CoreMessageLogger ;
99
99
import org .hibernate .internal .util .MathHelper ;
100
100
import org .hibernate .internal .util .StringHelper ;
101
101
import org .hibernate .internal .util .collections .ArrayHelper ;
110
110
import org .hibernate .persister .entity .Lockable ;
111
111
import org .hibernate .procedure .internal .StandardCallableStatementSupport ;
112
112
import org .hibernate .procedure .spi .CallableStatementSupport ;
113
+ import org .hibernate .query .Query ;
114
+ import org .hibernate .query .hql .HqlTranslator ;
115
+ import org .hibernate .query .spi .QueryEngine ;
116
+ import org .hibernate .query .spi .QueryOptions ;
113
117
import org .hibernate .query .sqm .CastType ;
114
118
import org .hibernate .query .sqm .FetchClauseType ;
115
119
import org .hibernate .query .sqm .IntervalType ;
116
120
import org .hibernate .query .sqm .NullOrdering ;
117
121
import org .hibernate .query .sqm .TemporalUnit ;
118
122
import org .hibernate .query .sqm .TrimSpec ;
119
- import org .hibernate .query .hql .HqlTranslator ;
120
- import org .hibernate .query .spi .QueryEngine ;
121
- import org .hibernate .query .spi .QueryOptions ;
122
123
import org .hibernate .query .sqm .mutation .internal .temptable .AfterUseAction ;
123
124
import org .hibernate .query .sqm .mutation .internal .temptable .BeforeUseAction ;
124
125
import org .hibernate .query .sqm .mutation .internal .temptable .PersistentTableInsertStrategy ;
165
166
import org .hibernate .type .descriptor .sql .spi .DdlTypeRegistry ;
166
167
import org .hibernate .type .spi .TypeConfiguration ;
167
168
169
+ import org .jboss .logging .Logger ;
170
+
168
171
import jakarta .persistence .TemporalType ;
169
172
170
173
import static java .lang .Math .ceil ;
171
174
import static java .lang .Math .log ;
172
175
import static org .hibernate .internal .util .StringHelper .parseCommaSeparatedString ;
173
- import static org .hibernate .type .SqlTypes .*;
176
+ import static org .hibernate .type .SqlTypes .ARRAY ;
177
+ import static org .hibernate .type .SqlTypes .BIGINT ;
178
+ import static org .hibernate .type .SqlTypes .BINARY ;
179
+ import static org .hibernate .type .SqlTypes .BLOB ;
180
+ import static org .hibernate .type .SqlTypes .BOOLEAN ;
181
+ import static org .hibernate .type .SqlTypes .CHAR ;
182
+ import static org .hibernate .type .SqlTypes .CLOB ;
183
+ import static org .hibernate .type .SqlTypes .DATE ;
184
+ import static org .hibernate .type .SqlTypes .DECIMAL ;
185
+ import static org .hibernate .type .SqlTypes .DOUBLE ;
186
+ import static org .hibernate .type .SqlTypes .FLOAT ;
187
+ import static org .hibernate .type .SqlTypes .INTEGER ;
188
+ import static org .hibernate .type .SqlTypes .LONG32NVARCHAR ;
189
+ import static org .hibernate .type .SqlTypes .LONG32VARBINARY ;
190
+ import static org .hibernate .type .SqlTypes .LONG32VARCHAR ;
191
+ import static org .hibernate .type .SqlTypes .NCHAR ;
192
+ import static org .hibernate .type .SqlTypes .NCLOB ;
193
+ import static org .hibernate .type .SqlTypes .NUMERIC ;
194
+ import static org .hibernate .type .SqlTypes .NVARCHAR ;
195
+ import static org .hibernate .type .SqlTypes .REAL ;
196
+ import static org .hibernate .type .SqlTypes .SMALLINT ;
197
+ import static org .hibernate .type .SqlTypes .TIME ;
198
+ import static org .hibernate .type .SqlTypes .TIMESTAMP ;
199
+ import static org .hibernate .type .SqlTypes .TIMESTAMP_UTC ;
200
+ import static org .hibernate .type .SqlTypes .TIMESTAMP_WITH_TIMEZONE ;
201
+ import static org .hibernate .type .SqlTypes .TIME_WITH_TIMEZONE ;
202
+ import static org .hibernate .type .SqlTypes .TINYINT ;
203
+ import static org .hibernate .type .SqlTypes .VARBINARY ;
204
+ import static org .hibernate .type .SqlTypes .VARCHAR ;
205
+ import static org .hibernate .type .SqlTypes .isCharacterType ;
206
+ import static org .hibernate .type .SqlTypes .isFloatOrRealOrDouble ;
207
+ import static org .hibernate .type .SqlTypes .isIntegral ;
208
+ import static org .hibernate .type .SqlTypes .isNumericOrDecimal ;
209
+ import static org .hibernate .type .SqlTypes .isNumericType ;
210
+ import static org .hibernate .type .SqlTypes .isVarbinaryType ;
211
+ import static org .hibernate .type .SqlTypes .isVarcharType ;
174
212
import static org .hibernate .type .descriptor .DateTimeUtils .JDBC_ESCAPE_END ;
175
213
import static org .hibernate .type .descriptor .DateTimeUtils .JDBC_ESCAPE_START_DATE ;
176
214
import static org .hibernate .type .descriptor .DateTimeUtils .JDBC_ESCAPE_START_TIME ;
@@ -235,6 +273,8 @@ public abstract class Dialect implements ConversionContext {
235
273
private static final Pattern ESCAPE_CLOSING_COMMENT_PATTERN = Pattern .compile ( "\\ */" );
236
274
private static final Pattern ESCAPE_OPENING_COMMENT_PATTERN = Pattern .compile ( "/\\ *" );
237
275
276
+ private static final CoreMessageLogger LOG = Logger .getMessageLogger ( CoreMessageLogger .class , Dialect .class .getName () );
277
+
238
278
//needed for converting precision from decimal to binary digits
239
279
protected static final double LOG_BASE2OF10 = log (10 )/log (2 );
240
280
@@ -259,17 +299,31 @@ protected Dialect() {
259
299
260
300
protected Dialect (DatabaseVersion version ) {
261
301
this .version = version ;
302
+ checkVersion ();
262
303
registerDefaultKeywords ();
263
304
initDefaultProperties ();
264
305
}
265
306
266
307
protected Dialect (DialectResolutionInfo info ) {
267
308
this .version = info .makeCopy ();
309
+ checkVersion ();
268
310
registerDefaultKeywords ();
269
311
registerKeywords (info );
270
312
initDefaultProperties ();
271
313
}
272
314
315
+ protected void checkVersion () {
316
+ final DatabaseVersion version = getVersion ();
317
+ final DatabaseVersion minimumVersion = getMinimumSupportedVersion ();
318
+ if ( version != null && version .isBefore ( minimumVersion .getMajor (), minimumVersion .getMinor (), minimumVersion .getMicro () ) ) {
319
+ LOG .unsupportedDatabaseVersion (
320
+ getClass ().getName (),
321
+ version .getMajor () + "." + version .getMinor () + "." + version .getMicro (),
322
+ minimumVersion .getMajor () + "." + minimumVersion .getMinor () + "." + minimumVersion .getMicro ()
323
+ );
324
+ }
325
+ }
326
+
273
327
/**
274
328
* Set appropriate default values for configuration properties.
275
329
*/
@@ -475,6 +529,10 @@ public DatabaseVersion getVersion() {
475
529
return version ;
476
530
}
477
531
532
+ protected DatabaseVersion getMinimumSupportedVersion () {
533
+ return SimpleDatabaseVersion .ZERO_VERSION ;
534
+ }
535
+
478
536
/**
479
537
* Resolves the {@link SqlTypes} type code for the given column type name as reported by the database,
480
538
* or <code>null</code> if it can't be resolved.
@@ -1217,8 +1275,8 @@ public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType,
1217
1275
* {@link Types#LONGVARBINARY LONGVARBINARY} as the same type, since
1218
1276
* Hibernate doesn't really differentiate these types.
1219
1277
*
1220
- * @param column1 the first column type info
1221
- * @param column2 the second column type info
1278
+ * @param typeCode1 the first column type info
1279
+ * @param typeCode2 the second column type info
1222
1280
*
1223
1281
* @return {@code true} if the two type codes are equivalent
1224
1282
*/
0 commit comments