Merge pull request #2800 from ebean-orm/feature/refactor-databasePlatform

Refactor database platform - remove unused tableExists() method, rename getters to accessors
This commit is contained in:
Rob Bygrave
2022-08-25 12:01:49 +12:00
committed by GitHub
56 changed files with 160 additions and 174 deletions
@@ -237,7 +237,7 @@ public abstract class AbstractNamingConvention implements NamingConvention {
}
buffer.append(rhsTableName);
int maxTableNameLength = databasePlatform.getMaxTableNameLength();
int maxTableNameLength = databasePlatform.maxTableNameLength();
// maxConstraintNameLength is used as the max table name length.
if (buffer.length() > maxTableNameLength) {
@@ -3024,7 +3024,7 @@ public class DatabaseConfig {
public PersistBatch appliedPersistBatchOnCascade() {
if (persistBatchOnCascade == PersistBatch.INHERIT) {
// use the platform default (ALL except SQL Server which has NONE)
return databasePlatform.getPersistBatchOnCascade();
return databasePlatform.persistBatchOnCascade();
}
return persistBatchOnCascade;
}
@@ -288,7 +288,7 @@ public class DatabasePlatform {
/**
* Return the platform key.
*/
public Platform getPlatform() {
public Platform platform() {
return platform;
}
@@ -298,14 +298,14 @@ public class DatabasePlatform {
* "generic" is returned when no specific database platform has been set or found.
* </p>
*/
public String getName() {
public String name() {
return platform.name().toLowerCase();
}
/**
* Return true if we are using Sequence batch mode rather than STEP.
*/
public boolean isSequenceBatchMode() {
public boolean sequenceBatchMode() {
return sequenceBatchMode;
}
@@ -319,52 +319,52 @@ public class DatabasePlatform {
/**
* Return true if this database platform supports native ILIKE expression.
*/
public boolean isSupportsNativeIlike() {
public boolean supportsNativeIlike() {
return supportsNativeIlike;
}
/**
* Return true if the platform supports delete statements with table alias.
*/
public boolean isSupportsDeleteTableAlias() {
public boolean supportsDeleteTableAlias() {
return supportsDeleteTableAlias;
}
/**
* Return true if the collation is case sensitive.
* Return true if the collation is case-sensitive.
* <p>
* This is expected to be used for testing only.
* </p>
*/
public boolean isCaseSensitiveCollation() {
public boolean caseSensitiveCollation() {
return caseSensitiveCollation;
}
/**
* Return true if the platform supports SavepointId values.
*/
public boolean isSupportsSavepointId() {
public boolean supportsSavepointId() {
return supportsSavepointId;
}
/**
* Return true if migrations should use stored procedures.
*/
public boolean isUseMigrationStoredProcedures() {
public boolean useMigrationStoredProcedures() {
return useMigrationStoredProcedures;
}
/**
* Return true if the platform supports LIMIT with sql update.
*/
public boolean isInlineSqlUpdateLimit() {
public boolean inlineSqlUpdateLimit() {
return inlineSqlUpdateLimit;
}
/**
* Return the maximum number of bind values this database platform allows or zero for no limit.
*/
public int getMaxInBinding() {
public int maxInBinding() {
return maxInBinding;
}
@@ -374,14 +374,14 @@ public class DatabasePlatform {
* This is used when deriving names of intersection tables.
* </p>
*/
public int getMaxTableNameLength() {
public int maxTableNameLength() {
return maxTableNameLength;
}
/**
* Return the maximum constraint name allowed for the platform.
*/
public int getMaxConstraintNameLength() {
public int maxConstraintNameLength() {
return maxConstraintNameLength;
}
@@ -426,7 +426,7 @@ public class DatabasePlatform {
/**
* Return the DbEncrypt handler for this DB platform.
*/
public DbEncrypt getDbEncrypt() {
public DbEncrypt dbEncrypt() {
return dbEncrypt;
}
@@ -440,7 +440,7 @@ public class DatabasePlatform {
/**
* Return the history support for this database platform.
*/
public DbHistorySupport getHistorySupport() {
public DbHistorySupport historySupport() {
return historySupport;
}
@@ -454,14 +454,14 @@ public class DatabasePlatform {
/**
* So no except for Postgres and CockroachDB.
*/
public boolean isNativeArrayType() {
public boolean nativeArrayType() {
return false;
}
/**
* Return true if the DB supports native UUID.
*/
public boolean isNativeUuidType() {
public boolean nativeUuidType() {
return nativeUuidType;
}
@@ -470,21 +470,21 @@ public class DatabasePlatform {
*
* @return the db type map
*/
public DbPlatformTypeMapping getDbTypeMap() {
public DbPlatformTypeMapping dbTypeMap() {
return dbTypeMap;
}
/**
* Return the mapping for DB column default values.
*/
public DbDefaultValue getDbDefaultValue() {
public DbDefaultValue dbDefaultValue() {
return dbDefaultValue;
}
/**
* Return the column alias prefix.
*/
public String getColumnAliasPrefix() {
public String columnAliasPrefix() {
return columnAliasPrefix;
}
@@ -498,21 +498,21 @@ public class DatabasePlatform {
/**
* Return the close quote for quoted identifiers.
*/
public String getCloseQuote() {
public String closeQuote() {
return closeQuote;
}
/**
* Return the open quote for quoted identifiers.
*/
public String getOpenQuote() {
public String openQuote() {
return openQuote;
}
/**
* Return the JDBC type used to store booleans.
*/
public int getBooleanDbType() {
public int booleanDbType() {
return booleanDbType;
}
@@ -523,7 +523,7 @@ public class DatabasePlatform {
* example.
* </p>
*/
public int getBlobDbType() {
public int blobDbType() {
return blobDbType;
}
@@ -533,7 +533,7 @@ public class DatabasePlatform {
* This is typically Types.CLOB but for Postgres is Types.VARCHAR.
* </p>
*/
public int getClobDbType() {
public int clobDbType() {
return clobDbType;
}
@@ -542,7 +542,7 @@ public class DatabasePlatform {
* expanded form of (a=? and b=?) or (a=? and b=?) or ... rather than (a,b) in
* ((?,?),(?,?),...);
*/
public boolean isIdInExpandedForm() {
public boolean idInExpandedForm() {
return idInExpandedForm;
}
@@ -553,7 +553,7 @@ public class DatabasePlatform {
* This specifically is required for MySql when processing large results.
* </p>
*/
public boolean isForwardOnlyHintOnFindIterate() {
public boolean forwardOnlyHintOnFindIterate() {
return forwardOnlyHintOnFindIterate;
}
@@ -571,7 +571,7 @@ public class DatabasePlatform {
* This specifically is required for Hana which doesn't support CONCUR_UPDATABLE
* </p>
*/
public boolean isSupportsResultSetConcurrencyModeUpdatable() {
public boolean supportsResultSetConcurrencyModeUpdatable() {
return supportsResultSetConcurrencyModeUpdatable;
}
@@ -591,7 +591,7 @@ public class DatabasePlatform {
*
* @return the db identity
*/
public DbIdentity getDbIdentity() {
public DbIdentity dbIdentity() {
return dbIdentity;
}
@@ -604,14 +604,14 @@ public class DatabasePlatform {
*
* @return the sql limiter
*/
public SqlLimiter getSqlLimiter() {
public SqlLimiter sqlLimiter() {
return sqlLimiter;
}
/**
* Return the BasicSqlLimiter for limit/offset of SqlQuery queries.
*/
public BasicSqlLimiter getBasicSqlLimiter() {
public BasicSqlLimiter basicSqlLimiter() {
return basicSqlLimiter;
}
@@ -680,14 +680,14 @@ public class DatabasePlatform {
/**
* Set to true if select count against anonymous view requires an alias.
*/
public boolean isSelectCountWithAlias() {
public boolean selectCountWithAlias() {
return selectCountWithAlias;
}
/**
* Return true if select count with subquery needs column alias (SQL Server).
*/
public boolean isSelectCountWithColumnAlias() {
public boolean selectCountWithColumnAlias() {
return selectCountWithColumnAlias;
}
@@ -718,14 +718,14 @@ public class DatabasePlatform {
* <p>
* This may include an escape clause to disable a default escape character.
*/
public String getLikeClause(boolean rawLikeExpression) {
public String likeClause(boolean rawLikeExpression) {
return rawLikeExpression ? likeClauseRaw : likeClauseEscaped;
}
/**
* Return the platform default JDBC batch mode for persist cascade.
*/
public PersistBatch getPersistBatchOnCascade() {
public PersistBatch persistBatchOnCascade() {
return persistBatchOnCascade;
}
@@ -769,19 +769,6 @@ public class DatabasePlatform {
return false;
}
/**
* Return true if the table exists.
*/
public boolean tableExists(Connection connection, String catalog, String schema, String table) throws SQLException {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet tables = metaData.getTables(catalog, schema, table, null);
try {
return tables.next();
} finally {
JdbcClose.close(tables);
}
}
/**
* Escapes the like string for this DB-Platform
*/
@@ -119,7 +119,7 @@ public abstract class AbstractSqlQueryRequest implements CancelableQuery {
int firstRow = query.getFirstRow();
int maxRows = query.getMaxRows();
if (firstRow > 0 || maxRows > 0) {
return server.databasePlatform().getBasicSqlLimiter().limit(sql, firstRow, maxRows);
return server.databasePlatform().basicSqlLimiter().limit(sql, firstRow, maxRows);
}
return sql;
}
@@ -108,7 +108,7 @@ public final class DefaultContainer implements SpiContainer {
startServer(online, server);
}
DbOffline.reset();
log.log(INFO, "Started database[{0}] platform[{1}] in {2}ms", config.getName(), config.getDatabasePlatform().getPlatform(), System.currentTimeMillis() - start);
log.log(INFO, "Started database[{0}] platform[{1}] in {2}ms", config.getName(), config.getDatabasePlatform().platform(), System.currentTimeMillis() - start);
return server;
} finally {
lock.unlock();
@@ -251,7 +251,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public Platform platform() {
return databasePlatform.getPlatform();
return databasePlatform.platform();
}
@Override
@@ -318,7 +318,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
migrationRunner.setDefaultDbSchema(dbSchema);
}
migrationRunner.setName(config.getName());
Platform platform = config.getDatabasePlatform().getPlatform();
Platform platform = config.getDatabasePlatform().platform();
migrationRunner.setBasePlatform(platform.base().name().toLowerCase());
migrationRunner.setPlatform(platform.name().toLowerCase());
migrationRunner.loadProperties(config.getProperties());
@@ -560,7 +560,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
try (Connection connection = dataSource().getConnection()) {
for (String table : tables) {
executeSql(connection, databasePlatform.truncateStatement(table));
if (databasePlatform.getPlatform().base() == Platform.DB2) {
if (databasePlatform.platform().base() == Platform.DB2) {
// DB2 requires commit after each truncate statement
connection.commit();
}
@@ -105,7 +105,7 @@ final class InitDataSource {
}
boolean isPostgresAllQuotedIdentifiers() {
return config.isAllQuotedIdentifiers() && Platform.POSTGRES == config.getDatabasePlatform().getPlatform().base();
return config.isAllQuotedIdentifiers() && Platform.POSTGRES == config.getDatabasePlatform().platform().base();
}
private DataSource create(DataSourceConfig dsConfig, boolean readOnly) {
@@ -116,7 +116,7 @@ public final class InternalConfiguration {
this.databasePlatform = config.getDatabasePlatform();
this.expressionFactory = initExpressionFactory(config);
this.typeManager = new DefaultTypeManager(config, bootupClasses);
this.multiValueBind = createMultiValueBind(databasePlatform.getPlatform());
this.multiValueBind = createMultiValueBind(databasePlatform.platform());
this.deployInherit = new DeployInherit(bootupClasses);
this.deployCreateProperties = new DeployCreateProperties(typeManager);
this.deployUtil = new DeployUtil(typeManager, config);
@@ -171,7 +171,7 @@ public final class InternalConfiguration {
* Create and return the ExpressionFactory based on configuration and database platform.
*/
private ExpressionFactory initExpressionFactory(DatabaseConfig config) {
boolean nativeIlike = config.isExpressionNativeIlike() && databasePlatform.isSupportsNativeIlike();
boolean nativeIlike = config.isExpressionNativeIlike() && databasePlatform.supportsNativeIlike();
return new DefaultExpressionFactory(config.isExpressionEqualsWithNullAsNoop(), nativeIlike);
}
@@ -265,7 +265,7 @@ public final class InternalConfiguration {
DbExpressionHandler jsonHandler = getDbExpressionHandler(databasePlatform);
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
DbHistorySupport historySupport = databasePlatform.historySupport();
if (historySupport == null) {
return new Binder(typeManager, logManager, 0, false, jsonHandler, dataTimeZone, multiValueBind);
}
@@ -321,7 +321,7 @@ public final class InternalConfiguration {
}
private Platform getPlatform() {
return getDatabasePlatform().getPlatform();
return getDatabasePlatform().platform();
}
public DatabasePlatform getDatabasePlatform() {
@@ -577,7 +577,7 @@ public final class InternalConfiguration {
return QueryPlanManager.NOOP;
}
long threshold = config.getQueryPlanThresholdMicros();
return new CQueryPlanManager(transactionManager, threshold, queryPlanLogger(databasePlatform.getPlatform()), extraMetrics);
return new CQueryPlanManager(transactionManager, threshold, queryPlanLogger(databasePlatform.platform()), extraMetrics);
}
/**
@@ -100,7 +100,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
*/
@Override
public String dbLikeClause(boolean rawLikeExpression) {
return server.databasePlatform().getLikeClause(rawLikeExpression);
return server.databasePlatform().likeClause(rawLikeExpression);
}
/**
@@ -761,7 +761,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
* Return true if no MaxRows or use LIMIT in SQL update.
*/
public boolean isInlineSqlUpdateLimit() {
return query.getMaxRows() < 1 || server.databasePlatform().isInlineSqlUpdateLimit();
return query.getMaxRows() < 1 || server.databasePlatform().inlineSqlUpdateLimit();
}
public int forwardOnlyFetchSize() {
@@ -134,7 +134,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
this.encryptKeyManager = this.config.getEncryptKeyManager();
this.databasePlatform = this.config.getDatabasePlatform();
this.multiValueBind = config.getMultiValueBind();
this.idBinderFactory = new IdBinderFactory(databasePlatform.isIdInExpandedForm(), multiValueBind);
this.idBinderFactory = new IdBinderFactory(databasePlatform.idInExpandedForm(), multiValueBind);
this.queryPlanTTLSeconds = this.config.getQueryPlanTTLSeconds();
this.asOfViewSuffix = asOfViewSuffix(databasePlatform, this.config);
String versionsBetweenSuffix = versionsBetweenSuffix(databasePlatform, this.config);
@@ -142,7 +142,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
this.bootupClasses = config.getBootupClasses();
this.createProperties = config.getDeployCreateProperties();
this.namingConvention = this.config.getNamingConvention();
this.dbIdentity = config.getDatabasePlatform().getDbIdentity();
this.dbIdentity = config.getDatabasePlatform().dbIdentity();
this.deplyInherit = config.getDeployInherit();
this.deployUtil = config.getDeployUtil();
this.typeManager = deployUtil.getTypeManager();
@@ -196,7 +196,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* Return the AsOfViewSuffix based on the DbHistorySupport.
*/
private String asOfViewSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
DbHistorySupport historySupport = databasePlatform.historySupport();
// with historySupport returns a simple view suffix or the sql2011 as of timestamp suffix
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getAsOfViewSuffix(serverConfig.getAsOfViewSuffix());
}
@@ -205,7 +205,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
* Return the versions between timestamp suffix based on the DbHistorySupport.
*/
private String versionsBetweenSuffix(DatabasePlatform databasePlatform, DatabaseConfig serverConfig) {
DbHistorySupport historySupport = databasePlatform.getHistorySupport();
DbHistorySupport historySupport = databasePlatform.historySupport();
// with historySupport returns a simple view suffix or the sql2011 versions between timestamp suffix
return (historySupport == null) ? serverConfig.getAsOfViewSuffix() : historySupport.getVersionsBetweenSuffix(serverConfig.getAsOfViewSuffix());
}
@@ -1251,7 +1251,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
String primaryKeyColumn = desc.getSinglePrimaryKeyColumn();
seqName = namingConvention.getSequenceName(desc.getBaseTable(), primaryKeyColumn);
}
int stepSize = desc.setIdentitySequenceBatchMode(databasePlatform.isSequenceBatchMode());
int stepSize = desc.setIdentitySequenceBatchMode(databasePlatform.sequenceBatchMode());
desc.setIdGenerator(createSequenceIdGenerator(seqName, stepSize));
}
}
@@ -53,7 +53,7 @@ abstract class AnnotationBase {
AnnotationBase(DeployUtil util) {
this.util = util;
this.databasePlatform = util.getDbPlatform();
this.platform = databasePlatform.getPlatform();
this.platform = databasePlatform.platform();
this.namingConvention = util.getNamingConvention();
}
@@ -398,7 +398,7 @@ final class AnnotationFields extends AnnotationParser {
return;
}
if (dbEncString) {
DbEncrypt dbEncrypt = util.getDbPlatform().getDbEncrypt();
DbEncrypt dbEncrypt = util.getDbPlatform().dbEncrypt();
if (dbEncrypt != null) {
// check if we have a DB encryption function for this type
int jdbcType = prop.getScalarType().getJdbcType();
@@ -10,7 +10,7 @@ public final class DbExpressionHandlerFactory {
* Create and return the appropriate platform specific handing of expressions.
*/
public static DbExpressionHandler from(DatabasePlatform databasePlatform) {
Platform platform = databasePlatform.getPlatform().base();
Platform platform = databasePlatform.platform().base();
switch (platform) {
case H2:
return new H2DbExpression();
@@ -50,7 +50,7 @@ public final class DefaultPersister implements Persister {
this.server = server;
this.beanDescriptorManager = descMgr;
this.persistExecute = new DefaultPersistExecute(binder, server.config().getPersistBatchSize());
this.maxInBinding = server.databasePlatform().getMaxInBinding();
this.maxInBinding = server.databasePlatform().maxInBinding();
}
@Override
@@ -38,7 +38,7 @@ final class InsertMeta {
private final Platform platform;
InsertMeta(DatabasePlatform dbPlatform, BeanDescriptor<?> desc, Bindable shadowFKey, BindableId id, BindableList all) {
this.platform = dbPlatform.getPlatform();
this.platform = dbPlatform.platform();
this.discriminator = getDiscriminator(desc);
this.id = id;
this.all = all;
@@ -69,7 +69,7 @@ final class InsertMeta {
this.supportsSelectLastInsertedId = false;
} else {
this.identityDbColumns = new String[]{id.getIdentityColumn()};
this.supportsGetGeneratedKeys = dbPlatform.getDbIdentity().isSupportsGetGeneratedKeys();
this.supportsGetGeneratedKeys = dbPlatform.dbIdentity().isSupportsGetGeneratedKeys();
this.supportsSelectLastInsertedId = desc.supportsSelectLastInsertedId();
}
this.sqlNullId = genSql(true, tableName, false);
@@ -40,7 +40,7 @@ final class MetaFactory {
MetaFactory(DatabasePlatform dbPlatform) {
this.dbPlatform = dbPlatform;
// to bind encryption data before or after the encryption key
DbEncrypt dbEncrypt = dbPlatform.getDbEncrypt();
DbEncrypt dbEncrypt = dbPlatform.dbEncrypt();
boolean bindEncryptDataFirst = dbEncrypt == null || dbEncrypt.isBindEncryptDataFirst();
this.baseFact = new FactoryBaseProperties(bindEncryptDataFirst);
this.embeddedFact = new FactoryEmbedded(bindEncryptDataFirst);
@@ -60,11 +60,11 @@ final class CQueryBuilder {
this.binder = binder;
this.draftSupport = draftSupport;
this.historySupport = historySupport;
this.columnAliasPrefix = dbPlatform.getColumnAliasPrefix();
this.sqlLimiter = dbPlatform.getSqlLimiter();
this.columnAliasPrefix = dbPlatform.columnAliasPrefix();
this.sqlLimiter = dbPlatform.sqlLimiter();
this.rawSqlHandler = new CQueryBuilderRawSql(sqlLimiter, dbPlatform);
this.selectCountWithAlias = dbPlatform.isSelectCountWithAlias();
this.selectCountWithColumnAlias = dbPlatform.isSelectCountWithColumnAlias();
this.selectCountWithAlias = dbPlatform.selectCountWithAlias();
this.selectCountWithColumnAlias = dbPlatform.selectCountWithColumnAlias();
}
/**
@@ -118,10 +118,10 @@ final class CQueryBuilder {
private <T> String buildDeleteSql(OrmQueryRequest<T> request, String rootTableAlias, CQueryPredicates predicates, SqlTree sqlTree) {
String alias = alias(rootTableAlias);
if (sqlTree.noJoins() && !request.query().hasMaxRowsOrFirstRow()) {
if (dbPlatform.isSupportsDeleteTableAlias()) {
if (dbPlatform.supportsDeleteTableAlias()) {
// delete from table <alias> ...
return aliasReplace(buildSqlDelete("delete", request, predicates, sqlTree).getSql(), alias);
} else if (isMySql(dbPlatform.getPlatform())) {
} else if (isMySql(dbPlatform.platform())) {
return aliasReplace(buildSqlDelete("delete " + alias, request, predicates, sqlTree).getSql(), alias);
} else {
// simple - delete from table ...
@@ -380,7 +380,7 @@ final class CQueryBuilder {
}
private String nativeQueryPaging(SpiQuery<?> query, String sql) {
return dbPlatform.getBasicSqlLimiter().limit(sql, query.getFirstRow(), query.getMaxRows());
return dbPlatform.basicSqlLimiter().limit(sql, query.getFirstRow(), query.getMaxRows());
}
/**
@@ -399,7 +399,7 @@ final class CQueryBuilder {
try {
// For SqlServer we need either "selectMethod=cursor" in the connection string or fetch explicitly a cursorable
// statement here by specifying ResultSet.CONCUR_UPDATABLE
PreparedStatement statement = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, dbPlatform.isSupportsResultSetConcurrencyModeUpdatable() ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
PreparedStatement statement = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, dbPlatform.supportsResultSetConcurrencyModeUpdatable() ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
predicates.bind(statement, connection);
ResultSet resultSet = statement.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();
@@ -43,13 +43,13 @@ public final class CQueryEngine {
this.dbPlatform = dbPlatform;
this.defaultFetchSizeFindEach = config.getJdbcFetchSizeFindEach();
this.defaultFetchSizeFindList = config.getJdbcFetchSizeFindList();
this.forwardOnlyHintOnFindIterate = dbPlatform.isForwardOnlyHintOnFindIterate();
this.historySupport = new CQueryHistorySupport(dbPlatform.getHistorySupport(), asOfTableMapping, config.getAsOfSysPeriod());
this.forwardOnlyHintOnFindIterate = dbPlatform.forwardOnlyHintOnFindIterate();
this.historySupport = new CQueryHistorySupport(dbPlatform.historySupport(), asOfTableMapping, config.getAsOfSysPeriod());
this.queryBuilder = new CQueryBuilder(dbPlatform, binder, historySupport, new CQueryDraftSupport(draftTableMap));
}
public int forwardOnlyFetchSize() {
Platform base = dbPlatform.getPlatform().base();
Platform base = dbPlatform.platform().base();
return Platform.MYSQL == base ? Integer.MIN_VALUE : 1;
}
@@ -120,7 +120,7 @@ public class TransactionManager implements SpiTransactionManager {
this.txnLogger = logManager.txn();
this.txnDebug = txnLogger.isDebug();
this.databasePlatform = options.config.getDatabasePlatform();
this.supportsSavepointId = databasePlatform.isSupportsSavepointId();
this.supportsSavepointId = databasePlatform.supportsSavepointId();
this.skipCacheAfterWrite = options.config.isSkipCacheAfterWrite();
this.notifyL2CacheInForeground = options.notifyL2CacheInForeground;
this.autoPersistUpdates = options.config.isAutoPersistUpdates();
@@ -50,7 +50,7 @@ final class DefaultTypeFactory {
return createBoolean(trueValue, falseValue);
}
// determine based on database platform configuration
int booleanDbType = config.getDatabasePlatform().getBooleanDbType();
int booleanDbType = config.getDatabasePlatform().booleanDbType();
if (booleanDbType == Types.BIT) {
return new ScalarTypeBoolean.BitBoolean();
}
@@ -167,7 +167,7 @@ public final class DefaultTypeManager implements TypeManager {
}
private PlatformArrayTypeFactory arrayTypeListFactory(DatabasePlatform databasePlatform) {
if (databasePlatform.isNativeArrayType()) {
if (databasePlatform.nativeArrayType()) {
return ScalarTypeArrayList.factory();
} else if (databasePlatform.isPlatform(Platform.H2)) {
return ScalarTypeArrayListH2.factory();
@@ -176,7 +176,7 @@ public final class DefaultTypeManager implements TypeManager {
}
private PlatformArrayTypeFactory arrayTypeSetFactory(DatabasePlatform databasePlatform) {
if (databasePlatform.isNativeArrayType()) {
if (databasePlatform.nativeArrayType()) {
return ScalarTypeArraySet.factory();
} else if (databasePlatform.isPlatform(Platform.H2)) {
return ScalarTypeArraySetH2.factory();
@@ -834,8 +834,8 @@ public final class DefaultTypeManager implements TypeManager {
*/
private void initialiseStandard(DatabaseConfig config) {
DatabasePlatform databasePlatform = config.getDatabasePlatform();
int platformClobType = databasePlatform.getClobDbType();
int platformBlobType = databasePlatform.getBlobDbType();
int platformClobType = databasePlatform.clobDbType();
int platformBlobType = databasePlatform.blobDbType();
nativeMap.put(DbPlatformType.HSTORE, hstoreType);
@@ -857,7 +857,7 @@ public final class DefaultTypeManager implements TypeManager {
}
PlatformConfig.DbUuid dbUuid = config.getPlatformConfig().getDbUuid();
if (offlineMigrationGeneration || (databasePlatform.isNativeUuidType() && dbUuid.useNativeType())) {
if (offlineMigrationGeneration || (databasePlatform.nativeUuidType() && dbUuid.useNativeType())) {
addType(UUID.class, new ScalarTypeUUIDNative());
} else {
// Store UUID as binary(16) or varchar(40)
@@ -58,7 +58,7 @@ public class DdlGenerator implements SpiDdlGenerator {
this.createOnly = config.isDdlCreateOnly();
this.dbSchema = config.getDbSchema();
final DatabasePlatform databasePlatform = server.databasePlatform();
this.platform = databasePlatform.getPlatform();
this.platform = databasePlatform.platform();
this.platformName = platform.base().name();
if (!config.getTenantMode().isDdlEnabled() && config.isDdlRun()) {
log.log(WARNING, "DDL can't be run on startup with TenantMode " + config.getTenantMode());
@@ -66,7 +66,7 @@ public class DdlGenerator implements SpiDdlGenerator {
this.useMigrationStoredProcedures = false;
} else {
this.runDdl = config.isDdlRun();
this.useMigrationStoredProcedures = config.getDatabasePlatform().isUseMigrationStoredProcedures();
this.useMigrationStoredProcedures = config.getDatabasePlatform().useMigrationStoredProcedures();
}
this.scriptTransform = createScriptTransform(config);
this.baseDir = initBaseDir();
@@ -209,7 +209,7 @@ public class DefaultDbMigration implements DbMigration {
public void setPlatform(DatabasePlatform databasePlatform) {
this.databasePlatform = databasePlatform;
if (!online) {
DbOffline.setPlatform(databasePlatform.getPlatform());
DbOffline.setPlatform(databasePlatform.platform());
}
}
@@ -388,8 +388,8 @@ public class DefaultDbMigration implements DbMigration {
if (extraDdl != null) {
List<DdlScript> ddlScript = extraDdl.getDdlScript();
for (DdlScript script : ddlScript) {
if (!script.isDrop() && matchPlatform(dbPlatform.getPlatform(), script.getPlatforms())) {
if (!checkSkip || dbPlatform.isUseMigrationStoredProcedures()) {
if (!script.isDrop() && matchPlatform(dbPlatform.platform(), script.getPlatforms())) {
if (!checkSkip || dbPlatform.useMigrationStoredProcedures()) {
writeExtraDdl(migrationDir, script);
}
}
@@ -40,7 +40,7 @@ class IndexMigration {
File init() {
pathStack.push("");
String name = "idx_" + databasePlatform.getPlatform().base().name().toLowerCase() + ".migrations";
String name = "idx_" + databasePlatform.platform().base().name().toLowerCase() + ".migrations";
return new File(topDir, name);
}
@@ -13,7 +13,7 @@ public class PlatformDdlBuilder {
*/
public static PlatformDdl create(DatabasePlatform platform) {
switch (platform.getPlatform()) {
switch (platform.platform()) {
case H2:
return new H2Ddl(platform);
case DB2:
@@ -121,7 +121,7 @@ public class BaseTableDdl implements TableDdl {
}
private List<String> getScriptsForPlatform(List<DdlScript> scripts) {
Platform searchPlatform = platformDdl.getPlatform().getPlatform();
Platform searchPlatform = platformDdl.getPlatform().platform();
for (DdlScript script : scripts) {
if (matchPlatform(searchPlatform, script.getPlatforms())) {
// just returns the first match (rather than appends them)
@@ -444,7 +444,7 @@ public class BaseTableDdl implements TableDdl {
}
private boolean platformInclude(String platforms) {
return matchPlatform(platformDdl.getPlatform().getPlatform(), platforms);
return matchPlatform(platformDdl.getPlatform().platform(), platforms);
}
/**
@@ -610,7 +610,7 @@ public class BaseTableDdl implements TableDdl {
public void generate(DdlWrite writer, DropTable dropTable) {
dropTable(writer.applyPostAlter(), dropTable.getName());
if (hasValue(dropTable.getSequenceCol())
&& platformDdl.getPlatform().getDbIdentity().isSupportsSequence()) {
&& platformDdl.getPlatform().dbIdentity().isSupportsSequence()) {
String sequenceName = dropTable.getSequenceName();
if (!hasValue(sequenceName)) {
sequenceName = namingConvention.getSequenceName(dropTable.getName(), dropTable.getSequenceCol());
@@ -24,7 +24,7 @@ public class MySqlDdl extends PlatformDdl {
this.dropUniqueConstraint = "drop index";
this.historyDdl = new MySqlHistoryDdl();
this.inlineComments = true;
this.useMigrationStoredProcedures = platform.isUseMigrationStoredProcedures();
this.useMigrationStoredProcedures = platform.useMigrationStoredProcedures();
}
/**
@@ -97,9 +97,9 @@ public class PlatformDdl {
public PlatformDdl(DatabasePlatform platform) {
this.platform = platform;
this.dbIdentity = platform.getDbIdentity();
this.dbDefaultValue = platform.getDbDefaultValue();
this.typeConverter = new PlatformTypeConverter(platform.getDbTypeMap());
this.dbIdentity = platform.dbIdentity();
this.dbDefaultValue = platform.dbDefaultValue();
this.typeConverter = new PlatformTypeConverter(platform.dbTypeMap());
}
/**
@@ -719,11 +719,11 @@ public class PlatformDdl {
* As 36^6 > 31^2, the resulting string is never longer as 6 chars.
*/
protected String maxConstraintName(String name) {
if (name.length() > platform.getMaxConstraintNameLength()) {
if (name.length() > platform.maxConstraintNameLength()) {
int hash = name.hashCode() & 0x7FFFFFFF;
name = VowelRemover.trim(name, 4);
if (name.length() > platform.getMaxConstraintNameLength()) {
return name.substring(0, platform.getMaxConstraintNameLength() - 7) + "_" + Integer.toString(hash, 36);
if (name.length() > platform.maxConstraintNameLength()) {
return name.substring(0, platform.maxConstraintNameLength() - 7) + "_" + Integer.toString(hash, 36);
}
}
return name;
@@ -56,7 +56,7 @@ public class ModelBuildContext {
if (constraintNaming.getMaxLength() != null) {
return constraintNaming.getMaxLength();
}
return new DefaultConstraintMaxLength(databasePlatform.getMaxConstraintNameLength());
return new DefaultConstraintMaxLength(databasePlatform.maxConstraintNameLength());
}
/**
@@ -49,7 +49,7 @@ public class HanaPlatformTest {
HanaPlatform platform = new HanaPlatform();
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)");
}
@@ -63,7 +63,7 @@ public class HanaPlatformTest {
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varbinary(16)");
}
}
@@ -38,7 +38,7 @@ public class SqlserverPlatformTest {
public void uuid_default() {
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("uniqueidentifier");
}
@@ -52,7 +52,7 @@ public class SqlserverPlatformTest {
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)");
}
@@ -64,7 +64,7 @@ public class SqlserverPlatformTest {
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("nvarchar(40)");
}
}
@@ -14,7 +14,7 @@ public class PlatformTypeConverterTest {
public void convert_withSuffix_expect_suffix() {
PostgresPlatform pg = new PostgresPlatform();
DbPlatformTypeMapping dbTypeMap = pg.getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = pg.dbTypeMap();
PlatformTypeConverter converter = new PlatformTypeConverter(dbTypeMap);
@@ -30,7 +30,7 @@ public class PlatformTypeConverterTest {
public void testConvert_given_postgres() throws Exception {
PostgresPlatform pg = new PostgresPlatform();
DbPlatformTypeMapping dbTypeMap = pg.getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = pg.dbTypeMap();
PlatformTypeConverter converter = new PlatformTypeConverter(dbTypeMap);
@@ -52,7 +52,7 @@ public class PlatformTypeConverterTest {
H2Platform platform = new H2Platform();
DbPlatformTypeMapping dbTypeMap = platform.getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = platform.dbTypeMap();
PlatformTypeConverter converter = new PlatformTypeConverter(dbTypeMap);
@@ -69,7 +69,7 @@ public class PlatformTypeConverterTest {
public void testConvertJsonTypes_given_postgres() {
PostgresPlatform platform = new PostgresPlatform();
DbPlatformTypeMapping dbTypeMap = platform.getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = platform.dbTypeMap();
PlatformTypeConverter converter = new PlatformTypeConverter(dbTypeMap);
@@ -84,7 +84,7 @@ public class PlatformTypeConverterTest {
public void testConvertJsonTypes_given_h2() {
H2Platform platform = new H2Platform();
DbPlatformTypeMapping dbTypeMap = platform.getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = platform.dbTypeMap();
PlatformTypeConverter converter = new PlatformTypeConverter(dbTypeMap);
@@ -78,7 +78,7 @@ public abstract class BaseTestCase {
}
public boolean isPlatformBooleanNative() {
return Types.BOOLEAN == spiEbeanServer().databasePlatform().getBooleanDbType();
return Types.BOOLEAN == spiEbeanServer().databasePlatform().booleanDbType();
}
public boolean isPlatformOrderNullsSupport() {
@@ -86,11 +86,11 @@ public abstract class BaseTestCase {
}
public boolean isPlatformSupportsDeleteTableAlias() {
return spiEbeanServer().databasePlatform().isSupportsDeleteTableAlias();
return spiEbeanServer().databasePlatform().supportsDeleteTableAlias();
}
public boolean isPersistBatchOnCascade() {
return spiEbeanServer().databasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
return spiEbeanServer().databasePlatform().persistBatchOnCascade() != PersistBatch.NONE;
}
/**
@@ -101,7 +101,7 @@ public abstract class BaseTestCase {
}
protected Platform platform() {
return spiEbeanServer().databasePlatform().getPlatform().base();
return spiEbeanServer().databasePlatform().platform().base();
}
protected SpiEbeanServer spiEbeanServer() {
@@ -168,7 +168,7 @@ public abstract class BaseTestCase {
}
public boolean isPlatformCaseSensitive() {
return spiEbeanServer().databasePlatform().isCaseSensitiveCollation();
return spiEbeanServer().databasePlatform().caseSensitiveCollation();
}
public boolean isLimitOffset() {
@@ -248,7 +248,7 @@ public abstract class BaseTestCase {
}
public boolean isPlatformBooleanNative() {
return Types.BOOLEAN == spiEbeanServer().databasePlatform().getBooleanDbType();
return Types.BOOLEAN == spiEbeanServer().databasePlatform().booleanDbType();
}
public boolean isPlatformOrderNullsSupport() {
@@ -256,11 +256,11 @@ public abstract class BaseTestCase {
}
public boolean isPlatformSupportsDeleteTableAlias() {
return spiEbeanServer().databasePlatform().isSupportsDeleteTableAlias();
return spiEbeanServer().databasePlatform().supportsDeleteTableAlias();
}
public boolean isPersistBatchOnCascade() {
return spiEbeanServer().databasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
return spiEbeanServer().databasePlatform().persistBatchOnCascade() != PersistBatch.NONE;
}
/**
@@ -279,11 +279,11 @@ public abstract class BaseTestCase {
}
protected Platform platform() {
return spiEbeanServer().databasePlatform().getPlatform().base();
return spiEbeanServer().databasePlatform().platform().base();
}
protected IdType idType() {
return spiEbeanServer().databasePlatform().getDbIdentity().getIdType();
return spiEbeanServer().databasePlatform().dbIdentity().getIdType();
}
protected SpiEbeanServer spiEbeanServer() {
@@ -92,7 +92,7 @@ public class PlatformNoGeneratedKeysTest {
config.setName("h2_noGeneratedKeys");
OtherH2Platform platform = new OtherH2Platform();
DbIdentity dbIdentity = platform.getDbIdentity();
DbIdentity dbIdentity = platform.dbIdentity();
dbIdentity.setIdType(IdType.IDENTITY);
dbIdentity.setSupportsIdentity(true);
dbIdentity.setSupportsGetGeneratedKeys(false);
@@ -20,7 +20,7 @@ class DbTypeMapTest {
@Test
void testLookupRender_given_postgresPlatformType() {
PostgresPlatform pg = new PostgresPlatform();
DbPlatformTypeMapping dbTypeMap = pg.getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = pg.dbTypeMap();
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("text");
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("text");
@@ -36,7 +36,7 @@ class DbTypeMapTest {
@Test
void testLookupRender_given_mysql() {
DbPlatformTypeMapping dbTypeMap = new MySqlPlatform().getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = new MySqlPlatform().dbTypeMap();
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("longtext");
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("longtext");
@@ -52,7 +52,7 @@ class DbTypeMapTest {
@Test
void testLookupRender_given_sqlserver17() {
DbPlatformTypeMapping dbTypeMap = new SqlServer17Platform().getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = new SqlServer17Platform().dbTypeMap();
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("nvarchar(max)");
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("nvarchar(max)");
@@ -68,7 +68,7 @@ class DbTypeMapTest {
@Test
void testLookupRender_given_sqlserver16() {
DbPlatformTypeMapping dbTypeMap = new SqlServer16Platform().getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = new SqlServer16Platform().dbTypeMap();
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("text");
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("text");
@@ -84,7 +84,7 @@ class DbTypeMapTest {
@Test
void testLookupRender_given_oracle() {
DbPlatformTypeMapping dbTypeMap = new OraclePlatform().getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = new OraclePlatform().dbTypeMap();
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("clob");
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("clob");
@@ -100,7 +100,7 @@ class DbTypeMapTest {
@Test
void testLookupRender_given_h2() {
DbPlatformTypeMapping dbTypeMap = new H2Platform().getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = new H2Platform().dbTypeMap();
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("clob");
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("clob");
@@ -116,7 +116,7 @@ class DbTypeMapTest {
@Test
void testLookupRender_given_clickhouse() {
DbPlatformTypeMapping dbTypeMap = new ClickHousePlatform().getDbTypeMap();
DbPlatformTypeMapping dbTypeMap = new ClickHousePlatform().dbTypeMap();
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("String");
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("String");
@@ -16,7 +16,7 @@ public class HanaPlatformTest {
HanaPlatform platform = new HanaPlatform();
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)");
}
@@ -30,7 +30,7 @@ public class HanaPlatformTest {
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varbinary(16)");
}
}
@@ -15,7 +15,7 @@ public class SqlserverPlatformTest {
public void uuid_default() {
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("uniqueidentifier");
}
@@ -29,7 +29,7 @@ public class SqlserverPlatformTest {
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)");
}
@@ -41,7 +41,7 @@ public class SqlserverPlatformTest {
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("nvarchar(40)");
}
}
@@ -14,6 +14,6 @@ public class SqlServer2016PlatformTest {
@Test
public void testHistorySupport() {
SqlServer17Platform platform = new SqlServer17Platform();
assertTrue(platform.getHistorySupport() instanceof SqlServerHistorySupport);
assertTrue(platform.historySupport() instanceof SqlServerHistorySupport);
}
}
@@ -201,7 +201,7 @@ public class DbMigrationTest extends BaseTestCase {
System.err.println("FIXME: Oracle history support seems to be broken");
return;
}
DbHistorySupport history = server().pluginApi().databasePlatform().getHistorySupport();
DbHistorySupport history = server().pluginApi().databasePlatform().historySupport();
if (history == null) {
return;
}
@@ -46,22 +46,22 @@ class PlatformLikeTest {
@Test
void rawLike_escapeEmpty() {
for (DatabasePlatform platform : List.of(h2, pg, pg9, yugabyte, cockroach, mysql, mysql55, maria)) {
assertThat(platform.getLikeClause(true)).isEqualTo("like ? escape''");
assertThat(platform.getLikeClause(false)).isEqualTo("like ? escape'|'");
assertThat(platform.likeClause(true)).isEqualTo("like ? escape''");
assertThat(platform.likeClause(false)).isEqualTo("like ? escape'|'");
}
}
@Test
void ansi_rawLike() {
for (DatabasePlatform platform : List.of(sqlite, sqlAnywhere, sqlServer17, oracle, oracle11, oracle12, hana, db2Luw)) {
assertThat(platform.getLikeClause(true)).isEqualTo("like ?");
assertThat(platform.likeClause(true)).isEqualTo("like ?");
}
}
@Test
void escapeLike_noEscape() {
for (DatabasePlatform platform : List.of(sqlite, sqlServer17)) {
assertThat(platform.getLikeClause(false)).isEqualTo("like ?");
assertThat(platform.likeClause(false)).isEqualTo("like ?");
}
}
@@ -69,7 +69,7 @@ class PlatformLikeTest {
@Test
void ansi_escapeLike() {
for (DatabasePlatform platform : List.of(sqlAnywhere, oracle, oracle11, oracle12, hana, db2Luw)) {
assertThat(platform.getLikeClause(false)).isEqualTo("like ? escape'|'");
assertThat(platform.likeClause(false)).isEqualTo("like ? escape'|'");
}
}
@@ -136,7 +136,7 @@ public class TestEncrypt extends BaseTestCase {
assertEquals(EBasicEncrypt.Status.ONE, e2.getStatus());
SpiEbeanServer server = (SpiEbeanServer) DB.getDefault();
DbEncrypt dbEncrypt = server.databasePlatform().getDbEncrypt();
DbEncrypt dbEncrypt = server.databasePlatform().dbEncrypt();
if (dbEncrypt == null) {
// can not test the where clause
@@ -134,7 +134,7 @@ public class TestBatchInsertSimple extends BaseTestCase {
Transaction transaction = DB.beginTransaction();
try {
transaction.setBatchMode(true);
transaction.setBatchOnCascade(PersistBatch.ALL.equals(spiEbeanServer().databasePlatform().getPersistBatchOnCascade()));
transaction.setBatchOnCascade(PersistBatch.ALL.equals(spiEbeanServer().databasePlatform().persistBatchOnCascade()));
transaction.setBatchSize(20);
// escalate based on batchOnCascade value
@@ -90,7 +90,7 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
Transaction txn = server.beginTransaction();
try {
assertThat(txn.isBatchMode()).isFalse();
assertThat(txn.isBatchOnCascade()).isSameAs(PersistBatch.ALL.equals(spiEbeanServer().databasePlatform().getPersistBatchOnCascade()));
assertThat(txn.isBatchOnCascade()).isSameAs(PersistBatch.ALL.equals(spiEbeanServer().databasePlatform().persistBatchOnCascade()));
failingOperation.run();
Assertions.fail("PersistenceException expected");
@@ -73,7 +73,7 @@ public class TestGeneratedKeys extends BaseTestCase {
private long readSequenceValue(Transaction tx, String sequence) throws SQLException {
String sql;
switch (spiEbeanServer().databasePlatform().getPlatform().base()) {
switch (spiEbeanServer().databasePlatform().platform().base()) {
case H2 :
sql = "select currval('" + sequence + "')";
break;
@@ -92,7 +92,7 @@ public class TestGeneratedKeys extends BaseTestCase {
default :
throw new UnsupportedOperationException("reading sequence value from "
+ spiEbeanServer().databasePlatform().getPlatform()
+ spiEbeanServer().databasePlatform().platform()
+ " is not supported.");
}
@@ -92,6 +92,6 @@ public class TestElementCollectionBasicCache extends BaseTestCase {
@Override
public boolean isPersistBatchOnCascade() {
return ((SpiEbeanServer) DB.getDefault()).databasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
return ((SpiEbeanServer) DB.getDefault()).databasePlatform().persistBatchOnCascade() != PersistBatch.NONE;
}
}
@@ -98,6 +98,6 @@ public class TestElementCollectionBasicMapCache extends BaseTestCase {
@Override
public boolean isPersistBatchOnCascade() {
return ((SpiEbeanServer) DB.getDefault()).databasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
return ((SpiEbeanServer) DB.getDefault()).databasePlatform().persistBatchOnCascade() != PersistBatch.NONE;
}
}
@@ -48,7 +48,7 @@ public class ClickHousePlatform extends DatabasePlatform {
}
@Override
public boolean isNativeArrayType() {
public boolean nativeArrayType() {
return true;
}
@@ -41,6 +41,6 @@ class H2PlatformTest {
}
private String defaultDefn(DbType type, DatabasePlatform dbPlatform) {
return dbPlatform.getDbTypeMap().get(type).renderType(0, 0);
return dbPlatform.dbTypeMap().get(type).renderType(0, 0);
}
}
@@ -93,7 +93,7 @@ public class HanaPlatform extends DatabasePlatform {
}
@Override
public boolean isUseMigrationStoredProcedures() {
public boolean useMigrationStoredProcedures() {
return true;
}
}
@@ -2,7 +2,6 @@ package io.ebean.platform.mysql;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.platform.mysql.MySqlPlatform;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -15,7 +14,7 @@ public class MySqlPlatformTest {
MySqlPlatform platform = new MySqlPlatform();
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar(40)");
}
@@ -28,7 +27,7 @@ public class MySqlPlatformTest {
config.setDbUuid(PlatformConfig.DbUuid.AUTO_BINARY);
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("binary(16)");
}
@@ -11,26 +11,26 @@ class OraclePlatformTest {
@Test
void columnAliasPrefix_Oracle11Platform() {
Oracle11Platform platform11 = new Oracle11Platform();
assertThat(platform11.getColumnAliasPrefix()).isEqualTo("c");
assertThat(platform11.columnAliasPrefix()).isEqualTo("c");
}
@Test
void columnAliasPrefix_Oracle12Platform() {
Oracle12Platform platform12 = new Oracle12Platform();
assertThat(platform12.getColumnAliasPrefix()).isEqualTo("c");
assertThat(platform12.columnAliasPrefix()).isEqualTo("c");
}
@Test
void columnAliasPrefix_OraclePlatform() {
OraclePlatform platform = new OraclePlatform();
assertThat(platform.getColumnAliasPrefix()).isNull();
assertThat(platform.columnAliasPrefix()).isNull();
}
@Test
void uuid_default() {
OraclePlatform platform = new OraclePlatform();
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("varchar2(40)");
}
@@ -42,7 +42,7 @@ class OraclePlatformTest {
platform.configure(config);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
assertThat(dbType.renderType(0, 0)).isEqualTo("raw(16)");
}
}
@@ -113,7 +113,7 @@ public class PostgresPlatform extends DatabasePlatform {
* So we can generate varchar[], int[], uuid[] column definitions and use the associated scalar types.
*/
@Override
public boolean isNativeArrayType() {
public boolean nativeArrayType() {
return true;
}
@@ -19,7 +19,7 @@ class PostgresPlatformTest {
PostgresPlatform platform = new PostgresPlatform();
platform.configure(new PlatformConfig());
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
DbPlatformType dbType = platform.dbTypeMap().get(DbPlatformType.UUID);
String columnDefn = dbType.renderType(0, 0);
assertThat(columnDefn).isEqualTo("uuid");
@@ -85,7 +85,7 @@ class PostgresPlatformTest {
}
private String defaultDefn(DbType type, DatabasePlatform dbPlatform) {
return dbPlatform.getDbTypeMap().get(type).renderType(0, 0);
return dbPlatform.dbTypeMap().get(type).renderType(0, 0);
}
}
@@ -122,7 +122,7 @@ abstract class SqlServerBasePlatform extends DatabasePlatform {
}
@Override
public boolean isUseMigrationStoredProcedures() {
public boolean useMigrationStoredProcedures() {
return true;
}
}
@@ -51,6 +51,6 @@ class SqlServerPlatformTest {
}
private String defaultDefn(DbType type, DatabasePlatform dbPlatform) {
return dbPlatform.getDbTypeMap().get(type).renderType(0, 0);
return dbPlatform.dbTypeMap().get(type).renderType(0, 0);
}
}