mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#913 - IllegalArgumentException: No enum constant com.avaje.ebean.config.Platform.HSQLDB
This commit is contained in:
@@ -121,7 +121,7 @@ public class DatabasePlatform {
|
||||
/**
|
||||
* The database platform name.
|
||||
*/
|
||||
protected String name = "generic";
|
||||
protected Platform platform = Platform.GENERIC;
|
||||
|
||||
protected String columnAliasPrefix = "c";
|
||||
|
||||
@@ -207,25 +207,31 @@ public class DatabasePlatform {
|
||||
}
|
||||
|
||||
private boolean platformMatch(Platform platform) {
|
||||
return platform == null || platform.name().equalsIgnoreCase(name);
|
||||
return platform == null || isPlatform(platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this matches the given platform.
|
||||
*/
|
||||
public boolean isPlatform(Platform platform) {
|
||||
return platform.name().equalsIgnoreCase(name);
|
||||
return this.platform.equals(platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the DatabasePlatform.
|
||||
* Return the platform key.
|
||||
*/
|
||||
public Platform getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the underlying Platform in lowercase.
|
||||
* <p>
|
||||
* "generic" is returned when no specific database platform has been set or
|
||||
* found.
|
||||
* "generic" is returned when no specific database platform has been set or found.
|
||||
* </p>
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
return platform.name().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean.config.dbplatform.db2;
|
||||
|
||||
import com.avaje.ebean.BackgroundExecutor;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.config.dbplatform.DbType;
|
||||
@@ -17,7 +18,7 @@ public class DB2Platform extends DatabasePlatform {
|
||||
|
||||
public DB2Platform() {
|
||||
super();
|
||||
this.name = "db2";
|
||||
this.platform = Platform.DB2;
|
||||
this.maxTableNameLength = 18;
|
||||
this.maxConstraintNameLength = 18;
|
||||
this.sqlLimiter = new Db2SqlLimiter();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean.config.dbplatform.h2;
|
||||
|
||||
import com.avaje.ebean.BackgroundExecutor;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.config.dbplatform.DbType;
|
||||
@@ -17,7 +18,7 @@ public class H2Platform extends DatabasePlatform {
|
||||
|
||||
public H2Platform() {
|
||||
super();
|
||||
this.name = "h2";
|
||||
this.platform = Platform.H2;
|
||||
this.dbEncrypt = new H2DbEncrypt();
|
||||
this.platformDdl = new H2Ddl(this);
|
||||
this.historySupport = new H2HistorySupport();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean.config.dbplatform.hsqldb;
|
||||
|
||||
import com.avaje.ebean.BackgroundExecutor;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.config.dbplatform.DbType;
|
||||
@@ -19,7 +20,7 @@ public class HsqldbPlatform extends DatabasePlatform {
|
||||
|
||||
public HsqldbPlatform() {
|
||||
super();
|
||||
this.name = "hsqldb";
|
||||
this.platform = Platform.HSQLDB;
|
||||
this.dbEncrypt = new H2DbEncrypt();
|
||||
this.platformDdl = new HsqldbDdl(this);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean.config.dbplatform.mysql;
|
||||
|
||||
import com.avaje.ebean.BackgroundExecutor;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.config.dbplatform.DbType;
|
||||
@@ -25,7 +26,7 @@ public class MySqlPlatform extends DatabasePlatform {
|
||||
|
||||
public MySqlPlatform() {
|
||||
super();
|
||||
this.name = "mysql";
|
||||
this.platform = Platform.MYSQL;
|
||||
this.useExtraTransactionOnIterateSecondaryQueries = true;
|
||||
this.likeClause = "like ? escape''";
|
||||
this.selectCountWithAlias = true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean.config.dbplatform.oracle;
|
||||
|
||||
import com.avaje.ebean.BackgroundExecutor;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.BasicSqlAnsiLimiter;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
@@ -20,7 +21,7 @@ public class OraclePlatform extends DatabasePlatform {
|
||||
|
||||
public OraclePlatform() {
|
||||
super();
|
||||
this.name = "oracle";
|
||||
this.platform = Platform.ORACLE;
|
||||
this.maxTableNameLength = 30;
|
||||
this.maxConstraintNameLength = 30;
|
||||
this.dbEncrypt = new OracleDbEncrypt();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean.config.dbplatform.postgres;
|
||||
|
||||
import com.avaje.ebean.BackgroundExecutor;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
@@ -23,7 +24,7 @@ public class PostgresPlatform extends DatabasePlatform {
|
||||
|
||||
public PostgresPlatform() {
|
||||
super();
|
||||
this.name = "postgres";
|
||||
this.platform = Platform.POSTGRES;
|
||||
this.supportsNativeIlike = true;
|
||||
this.likeClause = "like ? escape''";
|
||||
this.selectCountWithAlias = true;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform.sqlanywhere;
|
||||
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.config.dbplatform.DbType;
|
||||
@@ -18,7 +19,7 @@ public class SqlAnywherePlatform extends DatabasePlatform {
|
||||
|
||||
public SqlAnywherePlatform() {
|
||||
super();
|
||||
this.name = "sqlanywhere";
|
||||
this.platform = Platform.SQLANYWHERE;
|
||||
this.dbIdentity.setIdType(IdType.IDENTITY);
|
||||
|
||||
this.sqlLimiter = new SqlAnywhereLimiter();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebean.config.dbplatform.sqlite;
|
||||
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.config.dbplatform.DbType;
|
||||
@@ -12,7 +13,7 @@ public class SQLitePlatform extends DatabasePlatform {
|
||||
|
||||
public SQLitePlatform() {
|
||||
super();
|
||||
this.name = "sqlite";
|
||||
this.platform = Platform.SQLITE;
|
||||
this.platformDdl = new SQLiteDdl(this);
|
||||
|
||||
this.dbIdentity.setIdType(IdType.IDENTITY);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.avaje.ebean.config.dbplatform.sqlserver;
|
||||
|
||||
import com.avaje.ebean.config.PersistBatch;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.config.dbplatform.DbType;
|
||||
@@ -14,7 +15,7 @@ public class SqlServerPlatform extends DatabasePlatform {
|
||||
|
||||
public SqlServerPlatform() {
|
||||
super();
|
||||
this.name = "sqlserver";
|
||||
this.platform = Platform.SQLSERVER;
|
||||
// effectively disable persistBatchOnCascade mode for SQL Server
|
||||
// due to lack of support for getGeneratedKeys in batch mode
|
||||
this.persistBatchOnCascade = PersistBatch.NONE;
|
||||
|
||||
@@ -152,7 +152,7 @@ public class DbMigration {
|
||||
public void setPlatform(DatabasePlatform databasePlatform) {
|
||||
this.databasePlatform = databasePlatform;
|
||||
if (!online) {
|
||||
DbOffline.setPlatform(databasePlatform.getName());
|
||||
DbOffline.setPlatform(databasePlatform.getPlatform());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.avaje.ebeaninternal.server.core;
|
||||
import com.avaje.ebean.ExpressionFactory;
|
||||
import com.avaje.ebean.cache.ServerCacheManager;
|
||||
import com.avaje.ebean.config.ExternalTransactionManager;
|
||||
import com.avaje.ebean.config.Platform;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbHistorySupport;
|
||||
@@ -248,11 +249,11 @@ public class InternalConfiguration {
|
||||
*/
|
||||
private DbExpressionHandler getDbExpressionHandler(DatabasePlatform databasePlatform) {
|
||||
|
||||
String name = databasePlatform.getName();
|
||||
if ("postgres".equalsIgnoreCase(name)) {
|
||||
Platform platform = databasePlatform.getPlatform();
|
||||
if (platform == Platform.POSTGRES) {
|
||||
return new PostgresJsonExpression();
|
||||
}
|
||||
if ("oracle".equalsIgnoreCase(name)) {
|
||||
if (platform == Platform.ORACLE) {
|
||||
return new OracleDbExpression();
|
||||
}
|
||||
return new NotSupportedDbExpression();
|
||||
@@ -414,7 +415,7 @@ public class InternalConfiguration {
|
||||
if (tz == null) {
|
||||
return new NoDataTimeZone();
|
||||
}
|
||||
if (getDatabasePlatform().getName().toLowerCase().startsWith("oracle")) {
|
||||
if (getDatabasePlatform().getPlatform() == Platform.ORACLE) {
|
||||
return new CloneDataTimeZone(tz);
|
||||
} else {
|
||||
return new SimpleDataTimeZone(tz);
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class AnnotationBase {
|
||||
protected AnnotationBase(DeployUtil util) {
|
||||
this.util = util;
|
||||
this.databasePlatform = util.getDbPlatform();
|
||||
this.platform = Platform.valueOf(databasePlatform.getName().toUpperCase());
|
||||
this.platform = databasePlatform.getPlatform();
|
||||
this.namingConvention = util.getNamingConvention();
|
||||
}
|
||||
|
||||
|
||||
@@ -223,28 +223,7 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
}
|
||||
|
||||
private boolean isPostgres(DatabasePlatform databasePlatform) {
|
||||
return databasePlatform.getName().toLowerCase().startsWith("postgre");
|
||||
}
|
||||
|
||||
public boolean isKnownImmutable(Class<?> cls) {
|
||||
|
||||
if (cls == null) {
|
||||
// superclass from an interface
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cls.isPrimitive() || Object.class.equals(cls)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ScalarDataReader<?> scalarDataReader = getScalarDataReader(cls);
|
||||
return scalarDataReader != null;
|
||||
}
|
||||
|
||||
private ScalarType<?> register(ScalarType<?> st) {
|
||||
add(st);
|
||||
logger.debug("Registering ScalarType for " + st.getType() + " implemented using reflection");
|
||||
return st;
|
||||
return databasePlatform.getPlatform() == Platform.POSTGRES;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user