mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor extract separate modules for each platform from ebean-api dbplatform
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package io.ebean.platform.sqlite;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.DbPlatformType;
|
||||
import io.ebean.config.dbplatform.DbType;
|
||||
import io.ebean.config.dbplatform.IdType;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
public class SQLitePlatform extends DatabasePlatform {
|
||||
|
||||
public SQLitePlatform() {
|
||||
super();
|
||||
this.platform = Platform.SQLITE;
|
||||
this.dbIdentity.setIdType(IdType.IDENTITY);
|
||||
this.dbIdentity.setSupportsGetGeneratedKeys(false);
|
||||
this.dbIdentity.setSupportsSequence(false);
|
||||
this.dbIdentity.setSelectLastInsertedIdTemplate("select last_insert_rowid()");
|
||||
this.truncateTable = "delete from %s";
|
||||
this.booleanDbType = Types.INTEGER;
|
||||
this.likeClauseRaw = "like ?";
|
||||
this.likeClauseEscaped = "like ?";
|
||||
this.dbDefaultValue.setFalse("0");
|
||||
this.dbDefaultValue.setTrue("1");
|
||||
this.dbDefaultValue.setNow("CURRENT_TIMESTAMP");
|
||||
this.supportsResultSetConcurrencyModeUpdatable = false;
|
||||
|
||||
dbTypeMap.put(DbType.BIT, new DbPlatformType("int"));
|
||||
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("int"));
|
||||
dbTypeMap.put(DbType.BIGINT, new DbPlatformType("integer"));
|
||||
dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("integer"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void escapeLikeCharacter(char ch, StringBuilder sb) {
|
||||
sb.append(ch);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package io.ebean.platform.sqlite;
|
||||
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.DatabasePlatformProvider;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
|
||||
/**
|
||||
* Sqlite platform provider.
|
||||
*/
|
||||
public class SqlitePlatformProvider implements DatabasePlatformProvider {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Sqlite";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String name) {
|
||||
return name.equals("sqlite");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabasePlatform create(String name) {
|
||||
return new SQLitePlatform();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchByProductName(String productName) {
|
||||
return productName.contains("sqlite");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabasePlatform create(int majorVersion, int minorVersion, DatabaseMetaData meta, Connection connection) {
|
||||
return new SQLitePlatform();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchPlatform(Platform platform) {
|
||||
return Platform.SQLITE.equals(platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabasePlatform create(Platform platform) {
|
||||
return new SQLitePlatform();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Sqlite specific support.
|
||||
*/
|
||||
package io.ebean.platform.sqlite;
|
||||
Reference in New Issue
Block a user