昨日、同じ問題に遭遇しました。問題は、ebean フレームワークの sqlite ddl 構成内にあります。
しかし、com.avaje.ebean.config.dbplatform.SQLitePlatform クラスの独自の実装を作成することで、この問題を回避することができました。autoincrement キーワードを空の文字列に設定し、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 ファイルにパッケージ化します。Play アプリケーションのディレクトリ内に配置するlib
と、クラスローダーは元の実装の前にクラスをロードし、sqlite はこのカスタム実装によって生成された ddl を受け入れる必要があります。