1. application.properties Configuring SQLite Database
Spring.datasource.url = jdbc:sqlite:c:/test/sqlite/db/== SQLitespring.jpa.showTrue spring.jpa.hibernate.ddl-auto = updatespring.jpa.hibernate.naming-strategy == Test.utils.SQLiteDialectmultipart.maxFileSize=10MB
2. Add dialect files locally
Packagetest.utils;Importjava.sql.Types;ImportOrg.hibernate.dialect.Dialect;Importorg.hibernate.dialect.function.StandardSQLFunction;Importorg.hibernate.dialect.function.SQLFunctionTemplate;Importorg.hibernate.dialect.function.VarArgsSQLFunction;Importorg.hibernate.type.StandardBasicTypes; Public classSqlitedialectextendsdialect { PublicSqlitedialect () {Super(); Registercolumntype (Types.bit,"Integer"); Registercolumntype (Types.tinyint,"Tinyint"); Registercolumntype (Types.smallint,"SmallInt"); Registercolumntype (Types.integer,"Integer"); Registercolumntype (Types.bigint,"BigInt"); Registercolumntype (Types.float,"Float"); Registercolumntype (Types.real,"Real"); Registercolumntype (types.double,"Double"); Registercolumntype (Types.numeric,"Numeric"); Registercolumntype (Types.decimal,"Decimal"); Registercolumntype (Types.char,"Char"); Registercolumntype (Types.varchar,"VarChar"); Registercolumntype (Types.longvarchar,"LongVarChar"); Registercolumntype (Types.date,"Date"); Registercolumntype (Types.time,"Time"); Registercolumntype (Types.timestamp,"Timestamp"); Registercolumntype (Types.binary,"Blob"); Registercolumntype (Types.varbinary,"Blob"); Registercolumntype (Types.longvarbinary,"Blob"); //Registercolumntype (Types.null, "NULL");Registercolumntype (Types.blob, "BLOB"); Registercolumntype (Types.clob,"Clob"); Registercolumntype (Types.boolean,"Integer"); Registerfunction ("Concat",NewVarargssqlfunction (Standardbasictypes.string, "", "| |", "")); Registerfunction ("MoD",NewSqlfunctiontemplate (Standardbasictypes.integer, "1%? 2")); Registerfunction ("Substr",NewStandardsqlfunction ("substr", standardbasictypes.string)); Registerfunction ("Substring",NewStandardsqlfunction ("substr", standardbasictypes.string)); } Public BooleanSupportsidentitycolumns () {return true; } Public BooleanHasdatatypeinidentitycolumn () {return false; } PublicString getidentitycolumnstring () {return"Integer"; } PublicString getidentityselectstring () {return"Select Last_insert_rowid ()"; } Public BooleanSupportslimit () {return true; } PublicString getlimitstring (String query,BooleanHasoffset) { return NewStringBuffer (Query.length () +). Append (query). Append (Hasoffset?) "Limit?" Offset? ":" Limit? "). toString (); } Public BooleanSupportstemporarytables () {return true; } PublicString getcreatetemporarytablestring () {return"Create temporary table if not exists"; } Public BooleanDroptemporarytableafteruse () {return false; } Public Booleansupportscurrenttimestampselection () {return true; } Public Booleaniscurrenttimestampselectstringcallable () {return false; } PublicString getcurrenttimestampselectstring () {return"Select Current_timestamp"; } Public BooleanSupportsunionall () {return true; } Public Booleanhasaltertable () {return false; } Public Booleandropconstraints () {return false; } PublicString getaddcolumnstring () {return"Add Column"; } PublicString getforupdatestring () {return""; } Public Booleansupportsouterjoinforupdate () {return false; } PublicString getdropforeignkeystring () {Throw NewUnsupportedoperationexception ("No drop foreign key syntax supported by Sqlitedialect"); } Publicstring getaddforeignkeyconstraintstring (String constraintname, string[] ForeignKey, String referencedtable, String[] PrimaryKey,BooleanReferencesprimarykey) { Throw NewUnsupportedoperationexception ("No add foreign key syntax supported by Sqlitedialect"); } Publicstring getaddprimarykeyconstraintstring (String constraintname) {Throw NewUnsupportedoperationexception ("No add primary key syntax supported by Sqlitedialect"); } Public BooleanSupportsifexistsbeforetablename () {return true; } Public BooleanSupportscascadedelete () {return false; } @Override Public BooleanBindlimitparametersinreverseorder () {return true; }}
SQLite Database dialect configuration