Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	ebean-api/pom.xml
#	ebean-api/src/main/java/io/ebean/config/dbplatform/db2/BaseDB2Platform.java
#	ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.1.sql
#	ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.3.sql
#	ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/idx_db2.migrations
This commit is contained in:
Roland Praml
2022-01-28 07:53:45 +01:00
35 changed files with 340 additions and 66 deletions
@@ -55,12 +55,12 @@ public class DatabasePlatform {
protected boolean supportsSavepointId = true;
protected boolean useMigrationStoredProcedures = false;
/**
* Can we use native java time API objects in
* {@link ResultSet#getObject(int, Class)} and
* {@link PreparedStatement#setObject(int, Object)}.
*
*
* Not all drivers (DB2 e.g.) will support this.
*/
protected boolean supportsNativeJavaTime = true;
@@ -214,6 +214,8 @@ public class DatabasePlatform {
*/
protected PersistBatch persistBatchOnCascade = PersistBatch.ALL;
protected int maxInBinding;
/**
* The maximum length of table names - used specifically when derived
* default table names for intersection tables.
@@ -370,6 +372,13 @@ public class DatabasePlatform {
return inlineSqlUpdateLimit;
}
/**
* Return the maximum number of bind values this database platform allows or zero for no limit.
*/
public int getMaxInBinding() {
return maxInBinding;
}
/**
* Return the maximum table name length.
* <p>
@@ -15,16 +15,11 @@ import io.ebean.config.dbplatform.SqlErrorCodes;
/**
* DB2 specific platform.
*/
public class DB2Platform extends DatabasePlatform {
public abstract class BaseDB2Platform extends DatabasePlatform {
public DB2Platform() {
public BaseDB2Platform() {
super();
this.platform = Platform.DB2;
// Note: DB2 (at least LUW supports length up to 128)
// TOOD: Check if we need to introduce a new platform (DB2_LUW_11 ?)
// FIXME: This differs to original ebean branch, but is required run tests.
this.maxTableNameLength = 128;
this.maxConstraintNameLength = 128;
this.supportsNativeJavaTime = false;
this.truncateTable = "truncate table %s reuse storage ignore delete triggers immediate";
this.likeClauseRaw = "like ?";
@@ -0,0 +1,39 @@
package io.ebean.config.dbplatform.db2;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.config.dbplatform.DbType;
import io.ebean.config.dbplatform.SqlErrorCodes;
import java.sql.Types;
/**
* DB2 specific platform for i Series.
*
* @author Cédric Sougné
*/
public class DB2ForIPlatform extends BaseDB2Platform {
public DB2ForIPlatform() {
super();
this.platform = Platform.DB2FORI;
// Note: IBM i from 7.1 allow up to to 128
// TODO: Check if we need to introduce older platform (DB2ForI_6 ? but older
// documentation is not anymore published on ibm.com),
this.maxTableNameLength = 128;
this.maxConstraintNameLength = 128;
this.dbIdentity.setSupportsIdentity(true);
this.exceptionTranslator = new SqlErrorCodes().addAcquireLock("57033") // key -913
.addDuplicateKey("23505") // -803
// .addDataIntegrity("-407","-530","-531","-532","-543","-544","-545","-603","-667")
// we need SQLState, not code:
// https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/codes/src/tpc/db2z_n.html
.addDataIntegrity("23502", "23503", "23504", "23507", "23511", "23512", "23513", "42917", "23515")
.build();
booleanDbType = Types.SMALLINT;
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("smallint default 0"));
}
}
@@ -0,0 +1,20 @@
package io.ebean.config.dbplatform.db2;
import io.ebean.annotation.Platform;
/**
* DB2 specific platform for older DB2 versions. This platform is here for
* compatibility reasons. It uses a length limit of 18 chars for table and
* constraint names. Newer DB2 versions will support up to 128. It is strongly
* recommended to migrate to db2luw/DB2ForI or db2zos platform.
*/
public class DB2LegacyPlatform extends BaseDB2Platform {
public DB2LegacyPlatform() {
super();
this.platform = Platform.DB2;
// Note: DB2 (at least LUW supports length up to 128)
// TOOD: Check if we need to introduce a new platform (DB2_LUW_11 ?)
this.maxTableNameLength = 18;
this.maxConstraintNameLength = 18;
}
}
@@ -0,0 +1,17 @@
package io.ebean.config.dbplatform.db2;
import io.ebean.annotation.Platform;
/**
* DB2 platform for Linux/Unix/Windows.
* @author Roland Praml, FOCONIS AG
*
*/
public class DB2LuwPlatform extends BaseDB2Platform {
public DB2LuwPlatform() {
super();
this.platform = Platform.DB2LUW;
this.maxTableNameLength = 128;
this.maxConstraintNameLength = 128;
}
}
@@ -0,0 +1,18 @@
package io.ebean.config.dbplatform.db2;
import io.ebean.annotation.Platform;
/**
* DB2 platform for z/OS.
* Note: This platform is currently not tested!
* @author Roland Praml, FOCONIS AG
*
*/
public class DB2ZosPlatform extends BaseDB2Platform {
public DB2ZosPlatform() {
super();
this.platform = Platform.DB2ZOS;
this.maxTableNameLength = 128;
this.maxConstraintNameLength = 128;
}
}
@@ -23,6 +23,7 @@ public class OraclePlatform extends DatabasePlatform {
super();
this.platform = Platform.ORACLE;
this.supportsDeleteTableAlias = true;
this.maxInBinding = 1000;
this.maxTableNameLength = 30;
this.maxConstraintNameLength = 30;
this.dbEncrypt = new OracleDbEncrypt();
@@ -27,6 +27,7 @@ abstract class SqlServerBasePlatform extends DatabasePlatform {
// SQL Server unless we are using sequences
this.dbEncrypt = new SqlServerDbEncrypt();
this.persistBatchOnCascade = PersistBatch.NONE;
this.maxInBinding = 2000;
this.idInExpandedForm = true;
this.selectCountWithAlias = true;
this.selectCountWithColumnAlias = true;
@@ -0,0 +1,12 @@
package io.ebean.config.dbplatform.yugabyte;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
public class YugabytePlaform extends PostgresPlatform {
public YugabytePlaform() {
super();
this.platform = Platform.YUGABYTE;
}
}