SQLite Database dialect configuration

Source: Internet
Author: User
Tags sqlite sqlite database

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.