mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08d241d946 | ||
|
|
1c24ebf6dc |
@@ -34,11 +34,6 @@ public class PlatformConfig {
|
|||||||
*/
|
*/
|
||||||
private String databaseBooleanFalse;
|
private String databaseBooleanFalse;
|
||||||
|
|
||||||
/**
|
|
||||||
* For DB's using sequences this is the number of sequence values prefetched.
|
|
||||||
*/
|
|
||||||
private int databaseSequenceBatchSize = 20;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set for DB's that support both Sequence and Identity (and the default choice is not desired).
|
* Set for DB's that support both Sequence and Identity (and the default choice is not desired).
|
||||||
*/
|
*/
|
||||||
@@ -79,7 +74,6 @@ public class PlatformConfig {
|
|||||||
public PlatformConfig(PlatformConfig platformConfig) {
|
public PlatformConfig(PlatformConfig platformConfig) {
|
||||||
this.databaseBooleanFalse = platformConfig.databaseBooleanFalse;
|
this.databaseBooleanFalse = platformConfig.databaseBooleanFalse;
|
||||||
this.databaseBooleanTrue = platformConfig.databaseBooleanTrue;
|
this.databaseBooleanTrue = platformConfig.databaseBooleanTrue;
|
||||||
this.databaseSequenceBatchSize = platformConfig.databaseSequenceBatchSize;
|
|
||||||
this.idType = platformConfig.idType;
|
this.idType = platformConfig.idType;
|
||||||
this.geometrySRID = platformConfig.geometrySRID;
|
this.geometrySRID = platformConfig.geometrySRID;
|
||||||
this.dbUuid = platformConfig.dbUuid;
|
this.dbUuid = platformConfig.dbUuid;
|
||||||
@@ -173,20 +167,6 @@ public class PlatformConfig {
|
|||||||
this.databaseBooleanFalse = databaseBooleanFalse;
|
this.databaseBooleanFalse = databaseBooleanFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the number of DB sequence values that should be preallocated.
|
|
||||||
*/
|
|
||||||
public int getDatabaseSequenceBatchSize() {
|
|
||||||
return databaseSequenceBatchSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the number of DB sequence values that should be preallocated.
|
|
||||||
*/
|
|
||||||
public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) {
|
|
||||||
this.databaseSequenceBatchSize = databaseSequenceBatchSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Geometry SRID.
|
* Return the Geometry SRID.
|
||||||
*/
|
*/
|
||||||
@@ -294,7 +274,6 @@ public class PlatformConfig {
|
|||||||
public void loadSettings(PropertiesWrapper p) {
|
public void loadSettings(PropertiesWrapper p) {
|
||||||
|
|
||||||
idType = p.getEnum(IdType.class, "idType", idType);
|
idType = p.getEnum(IdType.class, "idType", idType);
|
||||||
databaseSequenceBatchSize = p.getInt("databaseSequenceBatchSize", databaseSequenceBatchSize);
|
|
||||||
databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue);
|
databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue);
|
||||||
databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse);
|
databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse);
|
||||||
databaseInetAddressVarchar = p.getBoolean("databaseInetAddressVarchar", databaseInetAddressVarchar);
|
databaseInetAddressVarchar = p.getBoolean("databaseInetAddressVarchar", databaseInetAddressVarchar);
|
||||||
|
|||||||
@@ -1050,18 +1050,6 @@ public class ServerConfig {
|
|||||||
this.lazyLoadBatchSize = lazyLoadBatchSize;
|
this.lazyLoadBatchSize = lazyLoadBatchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the number of sequences to fetch/preallocate when using DB sequences.
|
|
||||||
* <p>
|
|
||||||
* This is a performance optimisation to reduce the number times Ebean
|
|
||||||
* requests a sequence to be used as an Id for a bean (aka reduce network
|
|
||||||
* chatter).
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) {
|
|
||||||
platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the default JDBC fetchSize hint for findList queries.
|
* Return the default JDBC fetchSize hint for findList queries.
|
||||||
*/
|
*/
|
||||||
@@ -1828,32 +1816,6 @@ public class ServerConfig {
|
|||||||
this.platformConfig.setDatabaseBooleanFalse(databaseFalse);
|
this.platformConfig.setDatabaseBooleanFalse(databaseFalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the number of DB sequence values that should be preallocated.
|
|
||||||
*/
|
|
||||||
public int getDatabaseSequenceBatchSize() {
|
|
||||||
return platformConfig.getDatabaseSequenceBatchSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the number of DB sequence values that should be preallocated and cached
|
|
||||||
* by Ebean.
|
|
||||||
* <p>
|
|
||||||
* This is only used for DB's that use sequences and is a performance
|
|
||||||
* optimisation. This reduces the number of times Ebean needs to get a
|
|
||||||
* sequence value from the Database reducing network chatter.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* By default this value is 10 so when we need another Id (and don't have one
|
|
||||||
* in our cache) Ebean will fetch 10 id's from the database. Note that when
|
|
||||||
* the cache drops to have full (which is 5 by default) Ebean will fetch
|
|
||||||
* another batch of Id's in a background thread.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void setDatabaseSequenceBatch(int databaseSequenceBatchSize) {
|
|
||||||
this.platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the database platform name (can be null).
|
* Return the database platform name (can be null).
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -110,10 +110,6 @@ public class DatabasePlatform {
|
|||||||
*/
|
*/
|
||||||
protected DbIdentity dbIdentity = new DbIdentity();
|
protected DbIdentity dbIdentity = new DbIdentity();
|
||||||
|
|
||||||
protected boolean sequenceBatchMode = true;
|
|
||||||
|
|
||||||
protected int sequenceBatchSize = 20;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The history support for this database platform.
|
* The history support for this database platform.
|
||||||
*/
|
*/
|
||||||
@@ -235,7 +231,6 @@ public class DatabasePlatform {
|
|||||||
* Configure the platform given the server configuration.
|
* Configure the platform given the server configuration.
|
||||||
*/
|
*/
|
||||||
public void configure(PlatformConfig config) {
|
public void configure(PlatformConfig config) {
|
||||||
this.sequenceBatchSize = config.getDatabaseSequenceBatchSize();
|
|
||||||
this.caseSensitiveCollation = config.isCaseSensitiveCollation();
|
this.caseSensitiveCollation = config.isCaseSensitiveCollation();
|
||||||
configureIdType(config.getIdType());
|
configureIdType(config.getIdType());
|
||||||
configure(config, config.isAllQuotedIdentifiers());
|
configure(config, config.isAllQuotedIdentifiers());
|
||||||
@@ -298,20 +293,6 @@ public class DatabasePlatform {
|
|||||||
return platform.name().toLowerCase();
|
return platform.name().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if we are using Sequence batch mode rather than STEP.
|
|
||||||
*/
|
|
||||||
public boolean isSequenceBatchMode() {
|
|
||||||
return sequenceBatchMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to false to not use sequence batch mode but instead STEP mode.
|
|
||||||
*/
|
|
||||||
public void setSequenceBatchMode(boolean sequenceBatchMode) {
|
|
||||||
this.sequenceBatchMode = sequenceBatchMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if this database platform supports native ILIKE expression.
|
* Return true if this database platform supports native ILIKE expression.
|
||||||
*/
|
*/
|
||||||
@@ -381,13 +362,13 @@ public class DatabasePlatform {
|
|||||||
/**
|
/**
|
||||||
* Return a DB Sequence based IdGenerator.
|
* Return a DB Sequence based IdGenerator.
|
||||||
*
|
*
|
||||||
* @param be the BackgroundExecutor that can be used to load the sequence if
|
* @param be the BackgroundExecutor that can be used to load the sequence if
|
||||||
* desired
|
* desired
|
||||||
* @param ds the DataSource
|
* @param ds the DataSource
|
||||||
* @param stepSize the sequence allocation size as defined by mapping (defaults to 50)
|
* @param increment the sequence allocation size as defined by mapping (defaults to 50)
|
||||||
* @param seqName the name of the sequence
|
* @param seqName the name of the sequence
|
||||||
*/
|
*/
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
package io.ebean.config.dbplatform;
|
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Database sequence based IdGenerator using Sequence Step 1 but batch fetch many sequence values.
|
|
||||||
*/
|
|
||||||
public abstract class SequenceBatchIdGenerator extends SequenceIdGenerator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct where batchSize is the sequence step size.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public SequenceBatchIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
|
|
||||||
super(be, ds, seqName, batchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If allocateSize is large load some sequences in a background thread.
|
|
||||||
* <p>
|
|
||||||
* For example, when inserting a bean with a cascade on a OneToMany with many
|
|
||||||
* beans Ebean can call this to ensure .
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void preAllocateIds(int requestSize) {
|
|
||||||
if (allocationSize > 1 && requestSize > allocationSize) {
|
|
||||||
// only bother if allocateSize is bigger than
|
|
||||||
// the normal loading batchSize
|
|
||||||
if (requestSize > 100) {
|
|
||||||
// max out at 100 for now
|
|
||||||
requestSize = 100;
|
|
||||||
}
|
|
||||||
loadInBackground(requestSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the next set of Ids as the next value plus all the following numbers up to the step size.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected List<Long> readIds(ResultSet resultSet, int loadSize) throws SQLException {
|
|
||||||
|
|
||||||
List<Long> newIds = new ArrayList<>(loadSize);
|
|
||||||
while (resultSet.next()) {
|
|
||||||
newIds.add(resultSet.getLong(1));
|
|
||||||
}
|
|
||||||
return newIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -59,7 +59,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
this.allocationSize = allocationSize;
|
this.allocationSize = allocationSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getSql(int batchSize);
|
public abstract String getSql();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the sequence name.
|
* Returns the sequence name.
|
||||||
@@ -102,7 +102,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
maybeLoadMoreInBackground(size);
|
maybeLoadMoreInBackground(size);
|
||||||
} else {
|
} else {
|
||||||
loadMore(allocationSize);
|
loadMore();
|
||||||
}
|
}
|
||||||
return idList.pollFirst();
|
return idList.pollFirst();
|
||||||
}
|
}
|
||||||
@@ -116,8 +116,8 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMore(int requestSize) {
|
private void loadMore() {
|
||||||
List<Long> newIds = getMoreIds(requestSize);
|
List<Long> newIds = getMoreIds();
|
||||||
synchronized (monitor) {
|
synchronized (monitor) {
|
||||||
idList.addAll(newIds);
|
idList.addAll(newIds);
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
currentlyBackgroundLoading = true;
|
currentlyBackgroundLoading = true;
|
||||||
|
|
||||||
backgroundExecutor.execute(() -> {
|
backgroundExecutor.execute(() -> {
|
||||||
loadMore(requestSize);
|
loadMore();
|
||||||
synchronized (backgroundLoadMonitor) {
|
synchronized (backgroundLoadMonitor) {
|
||||||
currentlyBackgroundLoading = false;
|
currentlyBackgroundLoading = false;
|
||||||
}
|
}
|
||||||
@@ -150,14 +150,14 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
/**
|
/**
|
||||||
* Read the resultSet returning the list of Id values.
|
* Read the resultSet returning the list of Id values.
|
||||||
*/
|
*/
|
||||||
protected abstract List<Long> readIds(ResultSet resultSet, int loadSize) throws SQLException;
|
protected abstract List<Long> readIds(ResultSet resultSet) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get more Id's by executing a query and reading the Id's returned.
|
* Get more Id's by executing a query and reading the Id's returned.
|
||||||
*/
|
*/
|
||||||
protected List<Long> getMoreIds(int requestSize) {
|
protected List<Long> getMoreIds() {
|
||||||
|
|
||||||
String sql = getSql(requestSize);
|
String sql = getSql();
|
||||||
|
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@@ -168,7 +168,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
List<Long> newIds = readIds(resultSet, requestSize);
|
List<Long> newIds = readIds(resultSet);
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("seq:{} loaded:{} sql:{}", seqName, newIds.size(), sql);
|
logger.trace("seq:{} loaded:{} sql:{}", seqName, newIds.size(), sql);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,25 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public abstract class SequenceStepIdGenerator extends SequenceIdGenerator {
|
public abstract class SequenceStepIdGenerator extends SequenceIdGenerator {
|
||||||
|
|
||||||
|
private final String nextSql;
|
||||||
/**
|
/**
|
||||||
* Construct with stepSize (typically 50).
|
* Construct with stepSize (typically 50).
|
||||||
*/
|
*/
|
||||||
protected SequenceStepIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
protected SequenceStepIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int stepSize, String nextSql) {
|
||||||
super(be, ds, seqName, stepSize);
|
super(be, ds, seqName, stepSize);
|
||||||
|
this.nextSql = nextSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSql() {
|
||||||
|
return nextSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the next set of Ids as the next value plus all the following numbers up to the step size.
|
* Add the next set of Ids as the next value plus all the following numbers up to the step size.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected List<Long> readIds(ResultSet resultSet, int ignoreRequestSize) throws SQLException {
|
protected List<Long> readIds(ResultSet resultSet) throws SQLException {
|
||||||
|
|
||||||
List<Long> newIds = new ArrayList<>(allocationSize);
|
List<Long> newIds = new ArrayList<>(allocationSize);
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
long start = resultSet.getLong(1);
|
long start = resultSet.getLong(1);
|
||||||
|
|||||||
@@ -52,9 +52,8 @@ public class DB2Platform extends DatabasePlatform {
|
|||||||
* sequence values.
|
* sequence values.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
|
||||||
|
return new DB2Sequence(be, ds, seqName, increment);
|
||||||
return new DB2SequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package io.ebean.config.dbplatform.db2;
|
||||||
|
|
||||||
|
import io.ebean.BackgroundExecutor;
|
||||||
|
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DB2 specific sequence Id Generator.
|
||||||
|
*/
|
||||||
|
class DB2Sequence extends SequenceStepIdGenerator {
|
||||||
|
|
||||||
|
DB2Sequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
||||||
|
super(be, ds, seqName, stepSize, "values nextval for " + seqName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package io.ebean.config.dbplatform.db2;
|
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DB2 specific sequence Id Generator.
|
|
||||||
*/
|
|
||||||
public class DB2SequenceIdGenerator extends SequenceBatchIdGenerator {
|
|
||||||
|
|
||||||
private final String baseSql;
|
|
||||||
private final String unionBaseSql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct given a dataSource and sql to return the next sequence value.
|
|
||||||
*/
|
|
||||||
public DB2SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
|
|
||||||
super(be, ds, seqName, batchSize);
|
|
||||||
this.baseSql = "values nextval for " + seqName;
|
|
||||||
this.unionBaseSql = " union " + baseSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSql(int batchSize) {
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(baseSql);
|
|
||||||
for (int i = 1; i < batchSize; i++) {
|
|
||||||
sb.append(unionBaseSql);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package io.ebean.config.dbplatform.h2;
|
||||||
|
|
||||||
|
import io.ebean.BackgroundExecutor;
|
||||||
|
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
class H2DbSequence extends SequenceStepIdGenerator {
|
||||||
|
|
||||||
|
H2DbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
||||||
|
super(be, ds, seqName, stepSize, "select " + seqName + ".nextval");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -42,13 +42,9 @@ public class H2Platform extends DatabasePlatform {
|
|||||||
dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false));
|
dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a H2 specific sequence IdGenerator that supports batch fetching
|
|
||||||
* sequence values.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
|
||||||
return new H2SequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
|
return new H2DbSequence(be, ds, seqName, increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
package io.ebean.config.dbplatform.h2;
|
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* H2 specific sequence Id Generator.
|
|
||||||
*/
|
|
||||||
public class H2SequenceIdGenerator extends SequenceBatchIdGenerator {
|
|
||||||
|
|
||||||
private final String baseSql;
|
|
||||||
private final String unionBaseSql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct given a dataSource and sql to return the next sequence value.
|
|
||||||
*/
|
|
||||||
public H2SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
|
|
||||||
super(be, ds, seqName, batchSize);
|
|
||||||
this.baseSql = "select " + seqName + ".nextval";
|
|
||||||
this.unionBaseSql = " union " + baseSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSql(int batchSize) {
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(baseSql);
|
|
||||||
for (int i = 1; i < batchSize; i++) {
|
|
||||||
sb.append(unionBaseSql);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package io.ebean.config.dbplatform.hsqldb;
|
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
import io.ebean.annotation.Platform;
|
|
||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
|
||||||
import io.ebean.config.dbplatform.DbPlatformType;
|
|
||||||
import io.ebean.config.dbplatform.DbType;
|
|
||||||
import io.ebean.config.dbplatform.IdType;
|
|
||||||
import io.ebean.config.dbplatform.PlatformIdGenerator;
|
|
||||||
import io.ebean.config.dbplatform.h2.H2DbEncrypt;
|
|
||||||
import io.ebean.config.dbplatform.h2.H2SequenceIdGenerator;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* H2 specific platform.
|
|
||||||
*/
|
|
||||||
public class HsqldbPlatform extends DatabasePlatform {
|
|
||||||
|
|
||||||
public HsqldbPlatform() {
|
|
||||||
super();
|
|
||||||
this.platform = Platform.HSQLDB;
|
|
||||||
this.dbEncrypt = new H2DbEncrypt();
|
|
||||||
this.truncateTable = "delete from %s";
|
|
||||||
this.dbIdentity.setIdType(IdType.IDENTITY);
|
|
||||||
this.dbIdentity.setSupportsGetGeneratedKeys(true);
|
|
||||||
this.dbIdentity.setSupportsSequence(true);
|
|
||||||
this.dbIdentity.setSupportsIdentity(true);
|
|
||||||
|
|
||||||
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("integer", false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
|
||||||
return new H2SequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
/**
|
|
||||||
* Hsqldb specific support.
|
|
||||||
*/
|
|
||||||
package io.ebean.config.dbplatform.hsqldb;
|
|
||||||
@@ -44,8 +44,8 @@ public class NuoDbPlatform extends DatabasePlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
|
||||||
return new NuoDbSequence(be, ds, seqName, stepSize);
|
return new NuoDbSequence(be, ds, seqName, increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,20 +5,10 @@ import io.ebean.config.dbplatform.SequenceStepIdGenerator;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
public class NuoDbSequence extends SequenceStepIdGenerator {
|
class NuoDbSequence extends SequenceStepIdGenerator {
|
||||||
|
|
||||||
private final String nextSql;
|
NuoDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
||||||
|
super(be, ds, seqName, stepSize, "select next value for " + seqName + " from dual");
|
||||||
/**
|
|
||||||
* Construct where batchSize is the sequence step size.
|
|
||||||
*/
|
|
||||||
public NuoDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
|
||||||
super(be, ds, seqName, stepSize);
|
|
||||||
this.nextSql = "select next value for " + seqName + " from dual";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSql(int batchSize) {
|
|
||||||
return nextSql;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package io.ebean.config.dbplatform.oracle;
|
||||||
|
|
||||||
|
import io.ebean.BackgroundExecutor;
|
||||||
|
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
class OracleDbSequence extends SequenceStepIdGenerator {
|
||||||
|
|
||||||
|
OracleDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
||||||
|
super(be, ds, seqName, stepSize, "select " + seqName + ".nextval from dual");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -76,8 +76,8 @@ public class OraclePlatform extends DatabasePlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
|
||||||
return new OracleSequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
|
return new OracleDbSequence(be, ds, seqName, increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package io.ebean.config.dbplatform.oracle;
|
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Oracle specific sequence Id Generator.
|
|
||||||
*/
|
|
||||||
public class OracleSequenceIdGenerator extends SequenceBatchIdGenerator {
|
|
||||||
|
|
||||||
private final String baseSql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct given a dataSource and sql to return the next sequence value.
|
|
||||||
*/
|
|
||||||
public OracleSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
|
|
||||||
super(be, ds, seqName, batchSize);
|
|
||||||
this.baseSql = "select " + seqName + ".nextval, a from (select level as a FROM dual CONNECT BY level <= ";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSql(int batchSize) {
|
|
||||||
return baseSql + batchSize + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package io.ebean.config.dbplatform.postgres;
|
||||||
|
|
||||||
|
import io.ebean.BackgroundExecutor;
|
||||||
|
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
class PostgresDbSequence extends SequenceStepIdGenerator {
|
||||||
|
|
||||||
|
PostgresDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
||||||
|
super(be, ds, seqName, stepSize, "select nextval('" + seqName + "')");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -109,9 +109,8 @@ public class PostgresPlatform extends DatabasePlatform {
|
|||||||
* Create a Postgres specific sequence IdGenerator.
|
* Create a Postgres specific sequence IdGenerator.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
|
||||||
|
return new PostgresDbSequence(be, ds, seqName, increment);
|
||||||
return new PostgresSequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package io.ebean.config.dbplatform.postgres;
|
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
import io.ebean.config.dbplatform.SequenceBatchIdGenerator;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Postgres specific sequence Id Generator.
|
|
||||||
*/
|
|
||||||
public class PostgresSequenceIdGenerator extends SequenceBatchIdGenerator {
|
|
||||||
|
|
||||||
private final String baseSql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct given a dataSource and sql to return the next sequence value.
|
|
||||||
*/
|
|
||||||
public PostgresSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize) {
|
|
||||||
super(be, ds, seqName, batchSize);
|
|
||||||
this.baseSql = "select nextval('" + seqName + "'), s.generate_series from (select generate_series from generate_series(1,";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSql(int batchSize) {
|
|
||||||
return baseSql + batchSize + ") ) as s";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -36,7 +36,6 @@ abstract class SqlServerBasePlatform extends DatabasePlatform {
|
|||||||
this.dbIdentity.setSupportsGetGeneratedKeys(true);
|
this.dbIdentity.setSupportsGetGeneratedKeys(true);
|
||||||
this.dbIdentity.setSupportsIdentity(true);
|
this.dbIdentity.setSupportsIdentity(true);
|
||||||
this.dbIdentity.setSupportsSequence(true);
|
this.dbIdentity.setSupportsSequence(true);
|
||||||
this.sequenceBatchMode = false;
|
|
||||||
|
|
||||||
this.exceptionTranslator =
|
this.exceptionTranslator =
|
||||||
new SqlErrorCodes()
|
new SqlErrorCodes()
|
||||||
@@ -95,12 +94,9 @@ abstract class SqlServerBasePlatform extends DatabasePlatform {
|
|||||||
sb.append('[').append(ch).append(']');
|
sb.append('[').append(ch).append(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a Postgres specific sequence IdGenerator.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
|
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
|
||||||
return new SqlServerStepSequence(be, ds, seqName, stepSize);
|
return new SqlServerDbSequence(be, ds, seqName, increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package io.ebean.config.dbplatform.sqlserver;
|
||||||
|
|
||||||
|
import io.ebean.BackgroundExecutor;
|
||||||
|
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
class SqlServerDbSequence extends SequenceStepIdGenerator {
|
||||||
|
|
||||||
|
SqlServerDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
||||||
|
super(be, ds, seqName, stepSize, "select next value for " + seqName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package io.ebean.config.dbplatform.sqlserver;
|
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
public class SqlServerStepSequence extends SequenceStepIdGenerator {
|
|
||||||
|
|
||||||
private final String nextSql;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct where batchSize is the sequence step size.
|
|
||||||
*/
|
|
||||||
public SqlServerStepSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
|
|
||||||
super(be, ds, seqName, stepSize);
|
|
||||||
this.nextSql = "select next value for "+seqName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSql(int batchSize) {
|
|
||||||
return nextSql;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,6 @@ import io.ebean.config.dbplatform.cockroach.CockroachPlatform;
|
|||||||
import io.ebean.config.dbplatform.db2.DB2Platform;
|
import io.ebean.config.dbplatform.db2.DB2Platform;
|
||||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||||
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
||||||
import io.ebean.config.dbplatform.hsqldb.HsqldbPlatform;
|
|
||||||
import io.ebean.config.dbplatform.mysql.MySql55Platform;
|
import io.ebean.config.dbplatform.mysql.MySql55Platform;
|
||||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||||
import io.ebean.config.dbplatform.nuodb.NuoDbPlatform;
|
import io.ebean.config.dbplatform.nuodb.NuoDbPlatform;
|
||||||
@@ -814,8 +813,6 @@ public class DefaultDbMigration implements DbMigration {
|
|||||||
switch (platform) {
|
switch (platform) {
|
||||||
case H2:
|
case H2:
|
||||||
return new H2Platform();
|
return new H2Platform();
|
||||||
case HSQLDB:
|
|
||||||
return new HsqldbPlatform();
|
|
||||||
case POSTGRES9:
|
case POSTGRES9:
|
||||||
return new Postgres9Platform();
|
return new Postgres9Platform();
|
||||||
case POSTGRES:
|
case POSTGRES:
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import io.ebean.config.dbplatform.cockroach.CockroachPlatform;
|
|||||||
import io.ebean.config.dbplatform.db2.DB2Platform;
|
import io.ebean.config.dbplatform.db2.DB2Platform;
|
||||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||||
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
||||||
import io.ebean.config.dbplatform.hsqldb.HsqldbPlatform;
|
|
||||||
import io.ebean.config.dbplatform.mysql.MySql55Platform;
|
import io.ebean.config.dbplatform.mysql.MySql55Platform;
|
||||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||||
import io.ebean.config.dbplatform.nuodb.NuoDbPlatform;
|
import io.ebean.config.dbplatform.nuodb.NuoDbPlatform;
|
||||||
@@ -164,8 +163,6 @@ public class DatabasePlatformFactory {
|
|||||||
return mysqlVersion(majorVersion, minorVersion);
|
return mysqlVersion(majorVersion, minorVersion);
|
||||||
} else if (dbProductName.contains("h2")) {
|
} else if (dbProductName.contains("h2")) {
|
||||||
return new H2Platform();
|
return new H2Platform();
|
||||||
} else if (dbProductName.contains("hsql database engine")) {
|
|
||||||
return new HsqldbPlatform();
|
|
||||||
} else if (dbProductName.contains("postgres")) {
|
} else if (dbProductName.contains("postgres")) {
|
||||||
return readPostgres(connection, majorVersion);
|
return readPostgres(connection, majorVersion);
|
||||||
} else if (dbProductName.contains("nuo")) {
|
} else if (dbProductName.contains("nuo")) {
|
||||||
|
|||||||
@@ -1401,13 +1401,13 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
|||||||
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 increment = desc.setIdentitySequenceDefaultIncrement();
|
||||||
desc.setIdGenerator(createSequenceIdGenerator(seqName, stepSize));
|
desc.setIdGenerator(createSequenceIdGenerator(seqName, increment));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlatformIdGenerator createSequenceIdGenerator(String seqName, int stepSize) {
|
private PlatformIdGenerator createSequenceIdGenerator(String seqName, int increment) {
|
||||||
return databasePlatform.createSequenceIdGenerator(backgroundExecutor, dataSource, stepSize, seqName);
|
return databasePlatform.createSequenceIdGenerator(backgroundExecutor, dataSource, increment, seqName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createByteCode(DeployBeanDescriptor<?> deploy) {
|
private void createByteCode(DeployBeanDescriptor<?> deploy) {
|
||||||
|
|||||||
@@ -407,11 +407,8 @@ public class DeployBeanDescriptor<T> {
|
|||||||
identityMode.setSequenceGenerator(genName);
|
identityMode.setSequenceGenerator(genName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public int setIdentitySequenceDefaultIncrement() {
|
||||||
* Return the sequence increment to use given sequence batch mode.
|
return identityMode.setSequenceDefaultIncrement();
|
||||||
*/
|
|
||||||
public int setIdentitySequenceBatchMode(boolean sequenceBatchMode) {
|
|
||||||
return identityMode.setSequenceBatchMode(sequenceBatchMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdentityType(IdType type) {
|
public void setIdentityType(IdType type) {
|
||||||
|
|||||||
@@ -54,11 +54,8 @@ public class DeployIdentityMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int setSequenceBatchMode(boolean sequenceBatchMode) {
|
public int setSequenceDefaultIncrement() {
|
||||||
if (sequenceBatchMode) {
|
if (increment == 0) {
|
||||||
// Ebean batch fetching multiple sequence values
|
|
||||||
increment = 1;
|
|
||||||
} else if (increment == 0) {
|
|
||||||
// Use JPA default of 50
|
// Use JPA default of 50
|
||||||
increment = 50;
|
increment = 50;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-- Generated by ebean unknown at 2020-03-04T11:18:31.280668Z
|
-- Generated by ebean unknown at 2020-03-04T11:25:28.198394Z
|
||||||
create table asimple_bean (
|
create table asimple_bean (
|
||||||
id bigint generated by default as identity not null,
|
id bigint generated by default as identity not null,
|
||||||
name varchar(255),
|
name varchar(255),
|
||||||
@@ -275,7 +275,7 @@ create table drel_booking (
|
|||||||
constraint uq_drel_booking_client_invoice unique (client_invoice),
|
constraint uq_drel_booking_client_invoice unique (client_invoice),
|
||||||
constraint pk_drel_booking primary key (id)
|
constraint pk_drel_booking primary key (id)
|
||||||
);
|
);
|
||||||
create sequence drel_booking_seq increment by 1;
|
create sequence drel_booking_seq increment by 50;
|
||||||
|
|
||||||
create table bw_bean (
|
create table bw_bean (
|
||||||
id bigint generated by default as identity not null,
|
id bigint generated by default as identity not null,
|
||||||
@@ -396,7 +396,7 @@ create table sp_car_car (
|
|||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_sp_car_car primary key (id)
|
constraint pk_sp_car_car primary key (id)
|
||||||
);
|
);
|
||||||
create sequence sp_car_car_seq increment by 1;
|
create sequence sp_car_car_seq increment by 50;
|
||||||
|
|
||||||
create table sp_car_car_wheels (
|
create table sp_car_car_wheels (
|
||||||
car bigint not null,
|
car bigint not null,
|
||||||
@@ -417,7 +417,7 @@ create table sa_car (
|
|||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_sa_car primary key (id)
|
constraint pk_sa_car primary key (id)
|
||||||
);
|
);
|
||||||
create sequence sa_car_seq increment by 1;
|
create sequence sa_car_seq increment by 50;
|
||||||
|
|
||||||
create table car_accessory (
|
create table car_accessory (
|
||||||
id integer generated by default as identity not null,
|
id integer generated by default as identity not null,
|
||||||
@@ -864,7 +864,7 @@ create table sp_car_door (
|
|||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_sp_car_door primary key (id)
|
constraint pk_sp_car_door primary key (id)
|
||||||
);
|
);
|
||||||
create sequence sp_car_door_seq increment by 1;
|
create sequence sp_car_door_seq increment by 50;
|
||||||
|
|
||||||
create table earray_bean (
|
create table earray_bean (
|
||||||
id bigint generated by default as identity not null,
|
id bigint generated by default as identity not null,
|
||||||
@@ -1801,7 +1801,7 @@ create table gen_key_sequence (
|
|||||||
description varchar(255),
|
description varchar(255),
|
||||||
constraint pk_gen_key_sequence primary key (id)
|
constraint pk_gen_key_sequence primary key (id)
|
||||||
);
|
);
|
||||||
create sequence SEQ start with 1 increment by 1;
|
create sequence SEQ start with 1 increment by 50;
|
||||||
|
|
||||||
create table gen_key_table (
|
create table gen_key_table (
|
||||||
id bigint generated by default as identity not null,
|
id bigint generated by default as identity not null,
|
||||||
@@ -2018,7 +2018,7 @@ create table drel_invoice (
|
|||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_drel_invoice primary key (id)
|
constraint pk_drel_invoice primary key (id)
|
||||||
);
|
);
|
||||||
create sequence drel_invoice_seq increment by 1;
|
create sequence drel_invoice_seq increment by 50;
|
||||||
|
|
||||||
create table item (
|
create table item (
|
||||||
customer integer not null,
|
customer integer not null,
|
||||||
@@ -3614,7 +3614,7 @@ create table t_detail_with_other_namexxxyy (
|
|||||||
constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value),
|
constraint uq_t_detail_with_other_namexxxyy_some_unique_value unique (some_unique_value),
|
||||||
constraint pk_t_detail_with_other_namexxxyy primary key (id)
|
constraint pk_t_detail_with_other_namexxxyy primary key (id)
|
||||||
);
|
);
|
||||||
create sequence t_atable_detail_seq increment by 1;
|
create sequence t_atable_detail_seq increment by 50;
|
||||||
|
|
||||||
create table t_atable_thatisrelatively (
|
create table t_atable_thatisrelatively (
|
||||||
id integer not null,
|
id integer not null,
|
||||||
@@ -3623,7 +3623,7 @@ create table t_atable_thatisrelatively (
|
|||||||
active boolean default false not null,
|
active boolean default false not null,
|
||||||
constraint pk_t_atable_thatisrelatively primary key (id)
|
constraint pk_t_atable_thatisrelatively primary key (id)
|
||||||
);
|
);
|
||||||
create sequence t_atable_master_seq increment by 1;
|
create sequence t_atable_master_seq increment by 50;
|
||||||
|
|
||||||
create table ttruck_holder (
|
create table ttruck_holder (
|
||||||
id bigint generated by default as identity not null,
|
id bigint generated by default as identity not null,
|
||||||
@@ -3692,14 +3692,14 @@ create table tire (
|
|||||||
constraint uq_tire_wheel unique (wheel),
|
constraint uq_tire_wheel unique (wheel),
|
||||||
constraint pk_tire primary key (id)
|
constraint pk_tire primary key (id)
|
||||||
);
|
);
|
||||||
create sequence tire_seq increment by 1;
|
create sequence tire_seq increment by 50;
|
||||||
|
|
||||||
create table sa_tire (
|
create table sa_tire (
|
||||||
id bigint not null,
|
id bigint not null,
|
||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_sa_tire primary key (id)
|
constraint pk_sa_tire primary key (id)
|
||||||
);
|
);
|
||||||
create sequence sa_tire_seq increment by 1;
|
create sequence sa_tire_seq increment by 50;
|
||||||
|
|
||||||
create table tree_entity (
|
create table tree_entity (
|
||||||
id integer generated by default as identity not null,
|
id integer generated by default as identity not null,
|
||||||
@@ -3924,7 +3924,7 @@ create table wheel (
|
|||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_wheel primary key (id)
|
constraint pk_wheel primary key (id)
|
||||||
);
|
);
|
||||||
create sequence wheel_seq increment by 1;
|
create sequence wheel_seq increment by 50;
|
||||||
|
|
||||||
create table sa_wheel (
|
create table sa_wheel (
|
||||||
id bigint not null,
|
id bigint not null,
|
||||||
@@ -3933,7 +3933,7 @@ create table sa_wheel (
|
|||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_sa_wheel primary key (id)
|
constraint pk_sa_wheel primary key (id)
|
||||||
);
|
);
|
||||||
create sequence sa_wheel_seq increment by 1;
|
create sequence sa_wheel_seq increment by 50;
|
||||||
|
|
||||||
create table sp_car_wheel (
|
create table sp_car_wheel (
|
||||||
id bigint not null,
|
id bigint not null,
|
||||||
@@ -3941,7 +3941,7 @@ create table sp_car_wheel (
|
|||||||
version integer not null,
|
version integer not null,
|
||||||
constraint pk_sp_car_wheel primary key (id)
|
constraint pk_sp_car_wheel primary key (id)
|
||||||
);
|
);
|
||||||
create sequence sp_car_wheel_seq increment by 1;
|
create sequence sp_car_wheel_seq increment by 50;
|
||||||
|
|
||||||
create table g_who_props_otm (
|
create table g_who_props_otm (
|
||||||
id bigint generated by default as identity not null,
|
id bigint generated by default as identity not null,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-- Generated by ebean unknown at 2020-03-04T11:18:31.280668Z
|
-- Generated by ebean unknown at 2020-03-04T11:25:28.198394Z
|
||||||
alter table if exists bar drop constraint if exists fk_bar_foo_id;
|
alter table if exists bar drop constraint if exists fk_bar_foo_id;
|
||||||
drop index if exists ix_bar_foo_id;
|
drop index if exists ix_bar_foo_id;
|
||||||
|
|
||||||
|
|||||||
@@ -39,18 +39,18 @@ public class SequenceBatchIdGeneratorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSql(int batchSize) {
|
public String getSql() {
|
||||||
return "not used";
|
return "not used";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Long> readIds(ResultSet resultSet, int loadSize) {
|
protected List<Long> readIds(ResultSet resultSet) {
|
||||||
// do nothing
|
// do nothing
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Long> getMoreIds(int requestSize) {
|
protected List<Long> getMoreIds() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -13,9 +13,9 @@ import javax.sql.DataSource;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class SqlServerStepSequenceTest extends BaseTestCase {
|
public class SqlServerDbSequenceTest extends BaseTestCase {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SqlServerStepSequenceTest.class);
|
private static final Logger log = LoggerFactory.getLogger(SqlServerDbSequenceTest.class);
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@ForPlatform(Platform.SQLSERVER)
|
@ForPlatform(Platform.SQLSERVER)
|
||||||
@@ -29,7 +29,7 @@ public class SqlServerStepSequenceTest extends BaseTestCase {
|
|||||||
BackgroundExecutor be = server().getBackgroundExecutor();
|
BackgroundExecutor be = server().getBackgroundExecutor();
|
||||||
DataSource ds = server().getPluginApi().getDataSource();
|
DataSource ds = server().getPluginApi().getDataSource();
|
||||||
|
|
||||||
SqlServerStepSequence s = new SqlServerStepSequence(be, ds, "sqls_testseq_9876", 50);
|
SqlServerDbSequence s = new SqlServerDbSequence(be, ds, "sqls_testseq_9876", 50);
|
||||||
|
|
||||||
Object id = s.nextId(null);
|
Object id = s.nextId(null);
|
||||||
assertThat(id).isEqualTo(1L);
|
assertThat(id).isEqualTo(1L);
|
||||||
@@ -48,7 +48,6 @@ public class DbMigrationGenerateTest {
|
|||||||
// migration.addPlatform(Platform.SQLANYWHERE, "sqlanywhere"); and sqlanywhere
|
// migration.addPlatform(Platform.SQLANYWHERE, "sqlanywhere"); and sqlanywhere
|
||||||
migration.addPlatform(Platform.DB2, "db2");
|
migration.addPlatform(Platform.DB2, "db2");
|
||||||
migration.addPlatform(Platform.H2, "h2");
|
migration.addPlatform(Platform.H2, "h2");
|
||||||
migration.addPlatform(Platform.HSQLDB, "hsqldb");
|
|
||||||
migration.addPlatform(Platform.MYSQL, "mysql");
|
migration.addPlatform(Platform.MYSQL, "mysql");
|
||||||
migration.addPlatform(Platform.MYSQL55, "mysql55");
|
migration.addPlatform(Platform.MYSQL55, "mysql55");
|
||||||
migration.addPlatform(Platform.POSTGRES, "postgres");
|
migration.addPlatform(Platform.POSTGRES, "postgres");
|
||||||
|
|||||||
@@ -1,174 +0,0 @@
|
|||||||
-- Migrationscripts for ebean unittest
|
|
||||||
-- apply changes
|
|
||||||
create table migtest_ckey_assoc (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
assoc_one varchar(255),
|
|
||||||
constraint pk_migtest_ckey_assoc primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_ckey_detail (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
something varchar(255),
|
|
||||||
constraint pk_migtest_ckey_detail primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_ckey_parent (
|
|
||||||
one_key integer not null,
|
|
||||||
two_key varchar(127) not null,
|
|
||||||
name varchar(255),
|
|
||||||
version integer not null,
|
|
||||||
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_fk_cascade (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
one_id bigint,
|
|
||||||
constraint pk_migtest_fk_cascade primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_fk_cascade_one (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
constraint pk_migtest_fk_cascade_one primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_fk_none (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
one_id bigint,
|
|
||||||
constraint pk_migtest_fk_none primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_fk_none_via_join (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
one_id bigint,
|
|
||||||
constraint pk_migtest_fk_none_via_join primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_fk_one (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
constraint pk_migtest_fk_one primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_fk_set_null (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
one_id bigint,
|
|
||||||
constraint pk_migtest_fk_set_null primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_basic (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
status varchar(1),
|
|
||||||
status2 varchar(1) default 'N' not null,
|
|
||||||
name varchar(127),
|
|
||||||
description varchar(127),
|
|
||||||
some_date timestamp,
|
|
||||||
old_boolean boolean default false not null,
|
|
||||||
old_boolean2 boolean,
|
|
||||||
eref_id integer,
|
|
||||||
indextest1 varchar(127),
|
|
||||||
indextest2 varchar(127),
|
|
||||||
indextest3 varchar(127),
|
|
||||||
indextest4 varchar(127),
|
|
||||||
indextest5 varchar(127),
|
|
||||||
indextest6 varchar(127),
|
|
||||||
user_id integer not null,
|
|
||||||
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
|
|
||||||
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
|
|
||||||
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
|
|
||||||
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
|
|
||||||
constraint pk_migtest_e_basic primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_enum (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_status varchar(1),
|
|
||||||
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
|
|
||||||
constraint pk_migtest_e_enum primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_history (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_string varchar(255),
|
|
||||||
constraint pk_migtest_e_history primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_history2 (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_string varchar(255),
|
|
||||||
obsolete_string1 varchar(255),
|
|
||||||
obsolete_string2 varchar(255),
|
|
||||||
constraint pk_migtest_e_history2 primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_history3 (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_string varchar(255),
|
|
||||||
constraint pk_migtest_e_history3 primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_history4 (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_number integer,
|
|
||||||
constraint pk_migtest_e_history4 primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_history5 (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_number integer,
|
|
||||||
constraint pk_migtest_e_history5 primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_history6 (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_number1 integer,
|
|
||||||
test_number2 integer not null,
|
|
||||||
constraint pk_migtest_e_history6 primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_ref (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
name varchar(127) not null,
|
|
||||||
constraint uq_migtest_e_ref_name unique (name),
|
|
||||||
constraint pk_migtest_e_ref primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_e_softdelete (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
test_string varchar(255),
|
|
||||||
constraint pk_migtest_e_softdelete primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_mtm_c (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
name varchar(255),
|
|
||||||
constraint pk_migtest_mtm_c primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_mtm_m (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
name varchar(255),
|
|
||||||
constraint pk_migtest_mtm_m primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_oto_child (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
name varchar(255),
|
|
||||||
constraint pk_migtest_oto_child primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_oto_master (
|
|
||||||
id bigint generated by default as identity (start with 1) not null,
|
|
||||||
name varchar(255),
|
|
||||||
constraint pk_migtest_oto_master primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
|
||||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
|
||||||
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
|
|
||||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
|
||||||
|
|
||||||
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
|
|
||||||
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null;
|
|
||||||
|
|
||||||
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
|
|
||||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
-- Migrationscripts for ebean unittest
|
|
||||||
-- apply changes
|
|
||||||
create table migtest_e_user (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
constraint pk_migtest_e_user primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_mtm_c_migtest_mtm_m (
|
|
||||||
migtest_mtm_c_id integer not null,
|
|
||||||
migtest_mtm_m_id bigint not null,
|
|
||||||
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table migtest_mtm_m_migtest_mtm_c (
|
|
||||||
migtest_mtm_m_id bigint not null,
|
|
||||||
migtest_mtm_c_id integer not null,
|
|
||||||
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
alter table migtest_ckey_detail add column one_key integer;
|
|
||||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
|
||||||
|
|
||||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
|
|
||||||
alter table migtest_ckey_parent add column assoc_id integer;
|
|
||||||
|
|
||||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
|
||||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
|
|
||||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
|
||||||
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
|
||||||
alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id;
|
|
||||||
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
update migtest_e_basic set status = 'A' where status is null;
|
|
||||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
|
|
||||||
alter table migtest_e_basic alter column status set default 'A';
|
|
||||||
alter table migtest_e_basic alter column status set not null;
|
|
||||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
|
||||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
|
|
||||||
alter table migtest_e_basic alter column status2 varchar(127);
|
|
||||||
alter table migtest_e_basic alter column status2 drop default;
|
|
||||||
alter table migtest_e_basic alter column status2 set null;
|
|
||||||
|
|
||||||
-- rename all collisions;
|
|
||||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
|
|
||||||
|
|
||||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
|
||||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
|
|
||||||
alter table migtest_e_basic alter column user_id set null;
|
|
||||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
|
||||||
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
|
|
||||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
|
||||||
|
|
||||||
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
|
|
||||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
|
||||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
|
|
||||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
|
|
||||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
|
|
||||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
|
|
||||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
|
|
||||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
|
|
||||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
|
|
||||||
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
|
|
||||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
|
||||||
alter table migtest_e_history alter column test_string bigint;
|
|
||||||
comment on table migtest_e_history is 'We have history now';
|
|
||||||
|
|
||||||
-- NOTE: table has @History - special migration may be necessary
|
|
||||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
|
||||||
alter table migtest_e_history2 alter column test_string set default 'unknown';
|
|
||||||
alter table migtest_e_history2 alter column test_string set not null;
|
|
||||||
alter table migtest_e_history2 add column test_string2 varchar(255);
|
|
||||||
alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null;
|
|
||||||
alter table migtest_e_history2 add column new_column varchar(20);
|
|
||||||
|
|
||||||
alter table migtest_e_history4 alter column test_number bigint;
|
|
||||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
|
||||||
|
|
||||||
|
|
||||||
-- NOTE: table has @History - special migration may be necessary
|
|
||||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
|
||||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
|
||||||
alter table migtest_e_history6 alter column test_number1 set not null;
|
|
||||||
alter table migtest_e_history6 alter column test_number2 set null;
|
|
||||||
alter table migtest_e_softdelete add column deleted boolean default false not null;
|
|
||||||
|
|
||||||
alter table migtest_oto_child add column master_id bigint;
|
|
||||||
|
|
||||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
|
||||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
|
||||||
drop index if exists ix_migtest_e_basic_indextest1;
|
|
||||||
drop index if exists ix_migtest_e_basic_indextest5;
|
|
||||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id);
|
|
||||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
|
|
||||||
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
|
|
||||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
|
|
||||||
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
|
|
||||||
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
-- Migrationscripts for ebean unittest
|
|
||||||
-- apply changes
|
|
||||||
alter table migtest_e_basic drop column old_boolean;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop column old_boolean2;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop column eref_id;
|
|
||||||
|
|
||||||
alter table migtest_e_history2 drop column obsolete_string1;
|
|
||||||
|
|
||||||
alter table migtest_e_history2 drop column obsolete_string2;
|
|
||||||
|
|
||||||
drop table if exists migtest_e_ref;
|
|
||||||
drop sequence if exists migtest_e_ref_seq;
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
-- Migrationscripts for ebean unittest
|
|
||||||
-- apply changes
|
|
||||||
create table migtest_e_ref (
|
|
||||||
id integer generated by default as identity (start with 1) not null,
|
|
||||||
name varchar(127) not null,
|
|
||||||
constraint uq_migtest_e_ref_name unique (name),
|
|
||||||
constraint pk_migtest_e_ref primary key (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
alter table migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
|
|
||||||
alter table migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
|
|
||||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update cascade;
|
|
||||||
alter table migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
|
|
||||||
alter table migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id;
|
|
||||||
alter table migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id;
|
|
||||||
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update set null;
|
|
||||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
|
|
||||||
alter table migtest_e_basic alter column status drop default;
|
|
||||||
alter table migtest_e_basic alter column status set null;
|
|
||||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
|
||||||
|
|
||||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
|
||||||
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
|
|
||||||
alter table migtest_e_basic alter column status2 varchar(1);
|
|
||||||
alter table migtest_e_basic alter column status2 set default 'N';
|
|
||||||
alter table migtest_e_basic alter column status2 set not null;
|
|
||||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
|
|
||||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
|
|
||||||
|
|
||||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
|
||||||
alter table migtest_e_basic drop constraint if exists fk_migtest_e_basic_user_id;
|
|
||||||
alter table migtest_e_basic alter column user_id set default 23;
|
|
||||||
alter table migtest_e_basic alter column user_id set not null;
|
|
||||||
alter table migtest_e_basic add column old_boolean boolean default false not null;
|
|
||||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
|
||||||
alter table migtest_e_basic add column eref_id integer;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
|
|
||||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
|
|
||||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
|
|
||||||
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
|
|
||||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2);
|
|
||||||
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6);
|
|
||||||
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
|
|
||||||
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
|
|
||||||
comment on column migtest_e_history.test_string is '';
|
|
||||||
comment on table migtest_e_history is '';
|
|
||||||
alter table migtest_e_history2 alter column test_string drop default;
|
|
||||||
alter table migtest_e_history2 alter column test_string set null;
|
|
||||||
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
|
|
||||||
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
|
|
||||||
|
|
||||||
alter table migtest_e_history4 alter column test_number integer;
|
|
||||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
|
||||||
alter table migtest_e_history6 alter column test_number1 set null;
|
|
||||||
|
|
||||||
-- NOTE: table has @History - special migration may be necessary
|
|
||||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
|
||||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
|
||||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
|
||||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
|
||||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
|
||||||
drop index if exists ix_migtest_e_basic_indextest3;
|
|
||||||
drop index if exists ix_migtest_e_basic_indextest6;
|
|
||||||
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
|
|
||||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
|
|
||||||
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
-- Migrationscripts for ebean unittest
|
|
||||||
-- apply changes
|
|
||||||
alter table migtest_ckey_detail drop column one_key;
|
|
||||||
|
|
||||||
alter table migtest_ckey_detail drop column two_key;
|
|
||||||
|
|
||||||
alter table migtest_ckey_parent drop column assoc_id;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop column new_string_field;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop column new_boolean_field;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop column new_boolean_field2;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop column progress;
|
|
||||||
|
|
||||||
alter table migtest_e_basic drop column new_integer;
|
|
||||||
|
|
||||||
alter table migtest_e_history2 drop column test_string2;
|
|
||||||
|
|
||||||
alter table migtest_e_history2 drop column test_string3;
|
|
||||||
|
|
||||||
alter table migtest_e_history2 drop column new_column;
|
|
||||||
|
|
||||||
alter table migtest_e_history5 drop column test_boolean;
|
|
||||||
|
|
||||||
alter table migtest_e_softdelete drop column deleted;
|
|
||||||
|
|
||||||
alter table migtest_oto_child drop column master_id;
|
|
||||||
|
|
||||||
drop table if exists migtest_e_user;
|
|
||||||
drop sequence if exists migtest_e_user_seq;
|
|
||||||
drop table if exists migtest_mtm_c_migtest_mtm_m;
|
|
||||||
drop table if exists migtest_mtm_m_migtest_mtm_c;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
drop view order_agg_vw if exists ;
|
|
||||||
create view order_agg_vw as
|
|
||||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
|
||||||
sum(d.ship_qty * d.unit_price) as ship_total
|
|
||||||
from o_order_detail d
|
|
||||||
group by d.order_id;
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user