#1782 - ENH: Add truncate(Class<?>... types) and truncate(String... tables)

Remove truncateTableBefore and truncateTableAfter for now
This commit is contained in:
rob bygrave
2019-08-10 21:44:48 +12:00
parent bb7df71391
commit fea840c859
5 changed files with 7 additions and 29 deletions
@@ -140,8 +140,6 @@ public class DatabasePlatform {
protected Platform platform = Platform.GENERIC;
protected String truncateTable = "truncate table %s";
protected String truncateTableBefore;
protected String truncateTableAfter;
protected String columnAliasPrefix = "c";
@@ -719,20 +717,6 @@ public class DatabasePlatform {
return String.format(truncateTable, table);
}
/**
* Return a statement to execute prior to truncate (like disable foreign keys for mysql).
*/
public String truncateStatementBefore() {
return truncateTableBefore;
}
/**
* Return a statement to execute after truncate (like enable foreign keys for mysql).
*/
public String truncateStatementAfter() {
return truncateTableAfter;
}
/**
* Create the DB schema if it does not exist.
*/
@@ -26,8 +26,6 @@ public class H2Platform extends DatabasePlatform {
this.supportsDeleteTableAlias = true;
this.dbDefaultValue.setNow("now()");
this.columnAliasPrefix = null;
//this.truncateTableBefore = "set referential_integrity false";
//this.truncateTableAfter = "set referential_integrity true";
this.exceptionTranslator =
new SqlErrorCodes()
.addAcquireLock("50200","HYT00")
@@ -31,8 +31,6 @@ public class MySqlPlatform extends DatabasePlatform {
this.dbEncrypt = new MySqlDbEncrypt();
this.historySupport = new MySqlHistorySupport();
this.columnAliasPrefix = null;
//this.truncateTableBefore = "set foreign_key_checks = 0";
//this.truncateTableAfter = "set foreign_key_checks = 1";
this.dbIdentity.setIdType(IdType.IDENTITY);
this.dbIdentity.setSupportsGetGeneratedKeys(true);
this.dbIdentity.setSupportsIdentity(true);
@@ -653,11 +653,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
@Override
public void truncate(String... tables) {
try (Connection connection = getDataSource().getConnection()) {
executeSql(connection, databasePlatform.truncateStatementBefore());
for (String table : tables) {
executeSql(connection, databasePlatform.truncateStatement(table));
}
executeSql(connection, databasePlatform.truncateStatementAfter());
connection.commit();
} catch(SQLException e) {
throw new PersistenceException("Error executing truncate", e);