Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/main/java/io/ebean/config/PlatformConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public class PlatformConfig {
*/
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).
*/
Expand Down Expand Up @@ -79,7 +74,6 @@ public PlatformConfig() {
public PlatformConfig(PlatformConfig platformConfig) {
this.databaseBooleanFalse = platformConfig.databaseBooleanFalse;
this.databaseBooleanTrue = platformConfig.databaseBooleanTrue;
this.databaseSequenceBatchSize = platformConfig.databaseSequenceBatchSize;
this.idType = platformConfig.idType;
this.geometrySRID = platformConfig.geometrySRID;
this.dbUuid = platformConfig.dbUuid;
Expand Down Expand Up @@ -173,20 +167,6 @@ public void setDatabaseBooleanFalse(String 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.
*/
Expand Down Expand Up @@ -294,7 +274,6 @@ public List<CustomDbTypeMapping> getCustomTypeMappings() {
public void loadSettings(PropertiesWrapper p) {

idType = p.getEnum(IdType.class, "idType", idType);
databaseSequenceBatchSize = p.getInt("databaseSequenceBatchSize", databaseSequenceBatchSize);
databaseBooleanTrue = p.get("databaseBooleanTrue", databaseBooleanTrue);
databaseBooleanFalse = p.get("databaseBooleanFalse", databaseBooleanFalse);
databaseInetAddressVarchar = p.getBoolean("databaseInetAddressVarchar", databaseInetAddressVarchar);
Expand Down
38 changes: 0 additions & 38 deletions src/main/java/io/ebean/config/ServerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1050,18 +1050,6 @@ public void setLazyLoadBatchSize(int 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.
*/
Expand Down Expand Up @@ -1828,32 +1816,6 @@ public void setDatabaseBooleanFalse(String 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).
* <p>
Expand Down
31 changes: 6 additions & 25 deletions src/main/java/io/ebean/config/dbplatform/DatabasePlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ public enum OnQueryOnly {
*/
protected DbIdentity dbIdentity = new DbIdentity();

protected boolean sequenceBatchMode = true;

protected int sequenceBatchSize = 20;

/**
* The history support for this database platform.
*/
Expand Down Expand Up @@ -235,7 +231,6 @@ public PersistenceException translate(String message, SQLException e) {
* Configure the platform given the server configuration.
*/
public void configure(PlatformConfig config) {
this.sequenceBatchSize = config.getDatabaseSequenceBatchSize();
this.caseSensitiveCollation = config.isCaseSensitiveCollation();
configureIdType(config.getIdType());
configure(config, config.isAllQuotedIdentifiers());
Expand Down Expand Up @@ -298,20 +293,6 @@ public String getName() {
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.
*/
Expand Down Expand Up @@ -381,13 +362,13 @@ public boolean useExtraTransactionOnIterateSecondaryQueries() {
/**
* Return a DB Sequence based IdGenerator.
*
* @param be the BackgroundExecutor that can be used to load the sequence if
* desired
* @param ds the DataSource
* @param stepSize the sequence allocation size as defined by mapping (defaults to 50)
* @param seqName the name of the sequence
* @param be the BackgroundExecutor that can be used to load the sequence if
* desired
* @param ds the DataSource
* @param increment the sequence allocation size as defined by mapping (defaults to 50)
* @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;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqNa
this.allocationSize = allocationSize;
}

public abstract String getSql(int batchSize);
public abstract String getSql();

/**
* Returns the sequence name.
Expand Down Expand Up @@ -102,7 +102,7 @@ public Object nextId(Transaction t) {
if (size > 0) {
maybeLoadMoreInBackground(size);
} else {
loadMore(allocationSize);
loadMore();
}
return idList.pollFirst();
}
Expand All @@ -116,8 +116,8 @@ private void maybeLoadMoreInBackground(int currentSize) {
}
}

private void loadMore(int requestSize) {
List<Long> newIds = getMoreIds(requestSize);
private void loadMore() {
List<Long> newIds = getMoreIds();
synchronized (monitor) {
idList.addAll(newIds);
}
Expand All @@ -139,7 +139,7 @@ protected void loadInBackground(final int requestSize) {
currentlyBackgroundLoading = true;

backgroundExecutor.execute(() -> {
loadMore(requestSize);
loadMore();
synchronized (backgroundLoadMonitor) {
currentlyBackgroundLoading = false;
}
Expand All @@ -150,14 +150,14 @@ protected void loadInBackground(final int requestSize) {
/**
* 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.
*/
protected List<Long> getMoreIds(int requestSize) {
protected List<Long> getMoreIds() {

String sql = getSql(requestSize);
String sql = getSql();

Connection connection = null;
PreparedStatement statement = null;
Expand All @@ -168,7 +168,7 @@ protected List<Long> getMoreIds(int requestSize) {
statement = connection.prepareStatement(sql);
resultSet = statement.executeQuery();

List<Long> newIds = readIds(resultSet, requestSize);
List<Long> newIds = readIds(resultSet);
if (logger.isTraceEnabled()) {
logger.trace("seq:{} loaded:{} sql:{}", seqName, newIds.size(), sql);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@
*/
public abstract class SequenceStepIdGenerator extends SequenceIdGenerator {

private final String nextSql;
/**
* 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);
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.
*/
@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);
if (resultSet.next()) {
long start = resultSet.getLong(1);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/ebean/config/dbplatform/db2/DB2Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public DB2Platform() {
* sequence values.
*/
@Override
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {

return new DB2SequenceIdGenerator(be, ds, seqName, sequenceBatchSize);
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int increment, String seqName) {
return new DB2Sequence(be, ds, seqName, increment);
}

}
17 changes: 17 additions & 0 deletions src/main/java/io/ebean/config/dbplatform/db2/DB2Sequence.java
Original file line number Diff line number Diff line change
@@ -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);
}

}

This file was deleted.

14 changes: 14 additions & 0 deletions src/main/java/io/ebean/config/dbplatform/h2/H2DbSequence.java
Original file line number Diff line number Diff line change
@@ -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");
}

}
Loading