11package com .boylegu .springboot_vue .config ;
22
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-
133import java .sql .Types ;
14- import org .hibernate .dialect .Dialect ;
154
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 ;
196import org .hibernate .dialect .function .SQLFunctionTemplate ;
207import org .hibernate .dialect .function .StandardSQLFunction ;
218import org .hibernate .dialect .function .VarArgsSQLFunction ;
22- import org .hibernate .type .StandardBasicTypes ;
9+ import org .hibernate .type .StringType ;
2310
2411public class SQLiteDialect extends Dialect {
2512 public SQLiteDialect () {
26- registerColumnType (Types .BIT , "boolean " );
13+ registerColumnType (Types .BIT , "integer " );
2714 registerColumnType (Types .TINYINT , "tinyint" );
2815 registerColumnType (Types .SMALLINT , "smallint" );
2916 registerColumnType (Types .INTEGER , "integer" );
3017 registerColumnType (Types .BIGINT , "bigint" );
3118 registerColumnType (Types .FLOAT , "float" );
3219 registerColumnType (Types .REAL , "real" );
3320 registerColumnType (Types .DOUBLE , "double" );
34- registerColumnType (Types .NUMERIC , "numeric($p, $s) " );
21+ registerColumnType (Types .NUMERIC , "numeric" );
3522 registerColumnType (Types .DECIMAL , "decimal" );
3623 registerColumnType (Types .CHAR , "char" );
37- registerColumnType (Types .VARCHAR , "varchar($l) " );
24+ registerColumnType (Types .VARCHAR , "varchar" );
3825 registerColumnType (Types .LONGVARCHAR , "longvarchar" );
3926 registerColumnType (Types .DATE , "date" );
4027 registerColumnType (Types .TIME , "time" );
41- registerColumnType (Types .TIMESTAMP , "datetime " );
28+ registerColumnType (Types .TIMESTAMP , "timestamp " );
4229 registerColumnType (Types .BINARY , "blob" );
4330 registerColumnType (Types .VARBINARY , "blob" );
4431 registerColumnType (Types .LONGVARBINARY , "blob" );
32+ // registerColumnType(Types.NULL, "null");
4533 registerColumnType (Types .BLOB , "blob" );
4634 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 ));
8941 }
9042
9143 public boolean supportsIdentityColumns () {
@@ -124,12 +76,8 @@ public boolean supportsLimit() {
12476 return true ;
12577 }
12678
127- public boolean bindLimitParametersInReverseOrder () {
128- return true ;
129- }
130-
13179 protected String getLimitString (String query , boolean hasOffset ) {
132- return new StringBuffer (query .length ()+ 20 ).
80+ return new StringBuffer (query .length () + 20 ).
13381 append (query ).
13482 append (hasOffset ? " limit ? offset ?" : " limit ?" ).
13583 toString ();
@@ -144,7 +92,7 @@ public String getCreateTemporaryTableString() {
14492 }
14593
14694 public boolean dropTemporaryTableAfterUse () {
147- return true ; // TODO Validate
95+ return false ;
14896 }
14997
15098 public boolean supportsCurrentTimestampSelection () {
@@ -171,11 +119,9 @@ public boolean dropConstraints() {
171119 return false ;
172120 }
173121
174- /*
175- public String getAddColumnString() {
176- return "add column";
177- }
178- */
122+ public String getAddColumnString () {
123+ return "add column" ;
124+ }
179125
180126 public String getForUpdateString () {
181127 return "" ;
@@ -204,20 +150,6 @@ public boolean supportsIfExistsBeforeTableName() {
204150 }
205151
206152 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 () {
217153 return false ;
218154 }
219-
220- public String getSelectGUIDString () {
221- return "select hex(randomblob(16))" ;
222- }
223155}
0 commit comments