1
1
package com .boylegu .springboot_vue .config ;
2
2
3
- /*
4
- * The author disclaims copyright to this source code. In place of
5
- * a legal notice, here is a blessing:
6
- *
7
- * May you do good and not evil.
8
- * May you find forgiveness for yourself and forgive others.
9
- * May you share freely, never taking more than you give.
10
- *
11
- */
12
-
13
3
import java .sql .Types ;
14
- import org .hibernate .dialect .Dialect ;
15
4
16
- import org .hibernate .dialect .function .AbstractAnsiTrimEmulationFunction ;
17
- import org .hibernate .dialect .function .NoArgSQLFunction ;
18
- import org .hibernate .dialect .function .SQLFunction ;
5
+ import org .hibernate .dialect .Dialect ;
19
6
import org .hibernate .dialect .function .SQLFunctionTemplate ;
20
7
import org .hibernate .dialect .function .StandardSQLFunction ;
21
8
import org .hibernate .dialect .function .VarArgsSQLFunction ;
22
- import org .hibernate .type .StandardBasicTypes ;
9
+ import org .hibernate .type .StringType ;
23
10
24
11
public class SQLiteDialect extends Dialect {
25
12
public SQLiteDialect () {
26
- registerColumnType (Types .BIT , "boolean " );
13
+ registerColumnType (Types .BIT , "integer " );
27
14
registerColumnType (Types .TINYINT , "tinyint" );
28
15
registerColumnType (Types .SMALLINT , "smallint" );
29
16
registerColumnType (Types .INTEGER , "integer" );
30
17
registerColumnType (Types .BIGINT , "bigint" );
31
18
registerColumnType (Types .FLOAT , "float" );
32
19
registerColumnType (Types .REAL , "real" );
33
20
registerColumnType (Types .DOUBLE , "double" );
34
- registerColumnType (Types .NUMERIC , "numeric($p, $s) " );
21
+ registerColumnType (Types .NUMERIC , "numeric" );
35
22
registerColumnType (Types .DECIMAL , "decimal" );
36
23
registerColumnType (Types .CHAR , "char" );
37
- registerColumnType (Types .VARCHAR , "varchar($l) " );
24
+ registerColumnType (Types .VARCHAR , "varchar" );
38
25
registerColumnType (Types .LONGVARCHAR , "longvarchar" );
39
26
registerColumnType (Types .DATE , "date" );
40
27
registerColumnType (Types .TIME , "time" );
41
- registerColumnType (Types .TIMESTAMP , "datetime " );
28
+ registerColumnType (Types .TIMESTAMP , "timestamp " );
42
29
registerColumnType (Types .BINARY , "blob" );
43
30
registerColumnType (Types .VARBINARY , "blob" );
44
31
registerColumnType (Types .LONGVARBINARY , "blob" );
32
+ // registerColumnType(Types.NULL, "null");
45
33
registerColumnType (Types .BLOB , "blob" );
46
34
registerColumnType (Types .CLOB , "clob" );
47
- registerColumnType (Types .BOOLEAN , "boolean" );
48
-
49
- //registerFunction( "abs", new StandardSQLFunction("abs") );
50
- registerFunction ( "concat" , new VarArgsSQLFunction (StandardBasicTypes .STRING , "" , "||" , "" ) );
51
- //registerFunction( "length", new StandardSQLFunction("length", StandardBasicTypes.LONG) );
52
- //registerFunction( "lower", new StandardSQLFunction("lower") );
53
- registerFunction ( "mod" , new SQLFunctionTemplate (StandardBasicTypes .INTEGER , "?1 % ?2" ) );
54
- registerFunction ( "quote" , new StandardSQLFunction ("quote" , StandardBasicTypes .STRING ) );
55
- registerFunction ( "random" , new NoArgSQLFunction ("random" , StandardBasicTypes .INTEGER ) );
56
- registerFunction ( "round" , new StandardSQLFunction ("round" ) );
57
- registerFunction ( "substr" , new StandardSQLFunction ("substr" , StandardBasicTypes .STRING ) );
58
- registerFunction ( "substring" , new SQLFunctionTemplate ( StandardBasicTypes .STRING , "substr(?1, ?2, ?3)" ) );
59
- registerFunction ( "trim" , new AbstractAnsiTrimEmulationFunction () {
60
- protected SQLFunction resolveBothSpaceTrimFunction () {
61
- return new SQLFunctionTemplate (StandardBasicTypes .STRING , "trim(?1)" );
62
- }
63
-
64
- protected SQLFunction resolveBothSpaceTrimFromFunction () {
65
- return new SQLFunctionTemplate (StandardBasicTypes .STRING , "trim(?2)" );
66
- }
67
-
68
- protected SQLFunction resolveLeadingSpaceTrimFunction () {
69
- return new SQLFunctionTemplate (StandardBasicTypes .STRING , "ltrim(?1)" );
70
- }
71
-
72
- protected SQLFunction resolveTrailingSpaceTrimFunction () {
73
- return new SQLFunctionTemplate (StandardBasicTypes .STRING , "rtrim(?1)" );
74
- }
75
-
76
- protected SQLFunction resolveBothTrimFunction () {
77
- return new SQLFunctionTemplate (StandardBasicTypes .STRING , "trim(?1, ?2)" );
78
- }
79
-
80
- protected SQLFunction resolveLeadingTrimFunction () {
81
- return new SQLFunctionTemplate (StandardBasicTypes .STRING , "ltrim(?1, ?2)" );
82
- }
83
-
84
- protected SQLFunction resolveTrailingTrimFunction () {
85
- return new SQLFunctionTemplate (StandardBasicTypes .STRING , "rtrim(?1, ?2)" );
86
- }
87
- } );
88
- //registerFunction( "upper", new StandardSQLFunction("upper") );
35
+ registerColumnType (Types .BOOLEAN , "integer" );
36
+
37
+ registerFunction ("concat" , new VarArgsSQLFunction (StringType .INSTANCE , "" , "||" , "" ));
38
+ registerFunction ("mod" , new SQLFunctionTemplate (StringType .INSTANCE , "?1 % ?2" ));
39
+ registerFunction ("substr" , new StandardSQLFunction ("substr" , StringType .INSTANCE ));
40
+ registerFunction ("substring" , new StandardSQLFunction ("substr" , StringType .INSTANCE ));
89
41
}
90
42
91
43
public boolean supportsIdentityColumns () {
@@ -124,12 +76,8 @@ public boolean supportsLimit() {
124
76
return true ;
125
77
}
126
78
127
- public boolean bindLimitParametersInReverseOrder () {
128
- return true ;
129
- }
130
-
131
79
protected String getLimitString (String query , boolean hasOffset ) {
132
- return new StringBuffer (query .length ()+ 20 ).
80
+ return new StringBuffer (query .length () + 20 ).
133
81
append (query ).
134
82
append (hasOffset ? " limit ? offset ?" : " limit ?" ).
135
83
toString ();
@@ -144,7 +92,7 @@ public String getCreateTemporaryTableString() {
144
92
}
145
93
146
94
public boolean dropTemporaryTableAfterUse () {
147
- return true ; // TODO Validate
95
+ return false ;
148
96
}
149
97
150
98
public boolean supportsCurrentTimestampSelection () {
@@ -171,11 +119,9 @@ public boolean dropConstraints() {
171
119
return false ;
172
120
}
173
121
174
- /*
175
- public String getAddColumnString() {
176
- return "add column";
177
- }
178
- */
122
+ public String getAddColumnString () {
123
+ return "add column" ;
124
+ }
179
125
180
126
public String getForUpdateString () {
181
127
return "" ;
@@ -204,20 +150,6 @@ public boolean supportsIfExistsBeforeTableName() {
204
150
}
205
151
206
152
public boolean supportsCascadeDelete () {
207
- return true ;
208
- }
209
-
210
- /* not case insensitive for unicode characters by default (ICU extension needed)
211
- public boolean supportsCaseInsensitiveLike() {
212
- return true;
213
- }
214
- */
215
-
216
- public boolean supportsTupleDistinctCounts () {
217
153
return false ;
218
154
}
219
-
220
- public String getSelectGUIDString () {
221
- return "select hex(randomblob(16))" ;
222
- }
223
155
}
0 commit comments