昨天我遇到了同樣的問題。問題位於ebean框架的sqlite ddl配置中。
但是我能夠通過創建我自己的com.avaje.ebean.config.dbplatform.SQLitePlatform類的實現來解決該問題。這是一個快速破解這臺自動增量關鍵字爲空字符串,並重新定義了BIGINT類型爲整數:
package com.avaje.ebean.config.dbplatform;
import java.sql.Types;
import javax.sql.DataSource;
import com.avaje.ebean.BackgroundExecutor;
public class SQLitePlatform extends DatabasePlatform {
static {
System.err.println("\n\n!!! Custom SQLitePlatform class for ebean ORM loaded !!!!\n\n");
}
public SQLitePlatform() {
super();
this.name = "sqlite";
this.dbIdentity.setIdType(IdType.IDENTITY);
this.dbIdentity.setSupportsGetGeneratedKeys(false);
this.dbIdentity
.setSelectLastInsertedIdTemplate("select last_insert_rowid()");
this.openQuote = "\"";
this.closeQuote = "\"";
this.booleanDbType = Types.INTEGER;
dbTypeMap.put(Types.BIT, new DbType("int default 0"));
dbTypeMap.put(Types.BOOLEAN, new DbType("int default 0"));
dbTypeMap.put(Types.BIGINT, new DbType("integer"));
dbDdlSyntax.setInlinePrimaryKeyConstraint(true);
dbDdlSyntax.setIdentity("");
dbDdlSyntax.setDisableReferentialIntegrity("PRAGMA foreign_keys = OFF");
dbDdlSyntax.setEnableReferentialIntegrity("PRAGMA foreign_keys = ON");
}
/**
* Return null in case there is a sequence annotation.
*/
@Override
public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
DataSource ds, String seqName, int batchSize) {
return null;
}
}
編譯和打包類成jar文件。 當放在播放應用程序的lib
目錄中時,類加載器將在原始實現之前加載類,並且sqlite應接受由此自定義實現生成的ddl。
輝煌。謝謝! – ChuanRocks