Refactor DatabasePlatform - rename getters to accessors

Although this is public API these getters are not expected to be used
by application code so, I feel comfortable making this change.
This commit is contained in:
Rob Bygrave committed 2022-08-25 10:34:39 +12:00
1 parent 341b9a7449
commit 456086fb3c
56 files changed
+160 -161

No files matched your search

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