From 2ada43f6babd884d5ad8d37705d7a1ba36e13434 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Fri, 31 Jul 2015 20:53:31 +1200 Subject: [PATCH] No effective change - code cleanup - remove unused throws exception --- .../server/core/PersistRequestBean.java | 18 +- .../core/PersistRequestCallableSql.java | 4 +- .../server/core/PersistRequestOrmUpdate.java | 6 +- .../server/core/PersistRequestUpdateSql.java | 173 +++++++++--------- .../server/persist/BatchPostExecute.java | 4 +- 5 files changed, 100 insertions(+), 105 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java index f4513701e..55c78d428 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestBean.java @@ -1,13 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.persistence.OptimisticLockException; - import com.avaje.ebean.ValuePair; import com.avaje.ebean.annotation.ConcurrencyMode; import com.avaje.ebean.bean.EntityBean; @@ -29,6 +21,12 @@ import com.avaje.ebeaninternal.server.persist.dml.GenerateDmlRequest; import com.avaje.ebeaninternal.server.transaction.BeanDelta; import com.avaje.ebeaninternal.server.transaction.BeanPersistIdMap; +import javax.persistence.OptimisticLockException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * PersistRequest for insert update or delete of a bean. */ @@ -506,7 +504,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Check for optimistic concurrency exception. */ - public final void checkRowCount(int rowCount) throws SQLException { + public final void checkRowCount(int rowCount) { if (rowCount != 1) { String m = Message.msg("persist.conc2", "" + rowCount); throw new OptimisticLockException(m, null, bean); @@ -540,7 +538,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP /** * Post processing. */ - public void postExecute() throws SQLException { + public void postExecute() { if (controller != null) { controllerPost(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java index 3acc84255..56ae7e7b3 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestCallableSql.java @@ -66,7 +66,7 @@ public final class PersistRequestCallableSql extends PersistRequest { /** * Note the rowCount of the execution. */ - public void checkRowCount(int count) throws SQLException { + public void checkRowCount(int count) { this.rowCount = count; } @@ -79,7 +79,7 @@ public final class PersistRequestCallableSql extends PersistRequest { /** * Perform post execute processing for the CallableSql. */ - public void postExecute() throws SQLException { + public void postExecute() { if (transaction.isLogSummary()) { String m = "CallableSql label[" + callableSql.getLabel() + "]" + " rows[" + rowCount+ "]" + " bind[" + bindLog + "]"; diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java index 18ca6b584..78c37b9b4 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestOrmUpdate.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.SQLException; - import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiTransaction; import com.avaje.ebeaninternal.api.SpiUpdate; @@ -59,7 +57,7 @@ public final class PersistRequestOrmUpdate extends PersistRequest { /** * No concurrency checking so just note the rowCount. */ - public void checkRowCount(int count) throws SQLException { + public void checkRowCount(int count) { this.rowCount = count; } @@ -79,7 +77,7 @@ public final class PersistRequestOrmUpdate extends PersistRequest { /** * Perform post execute processing. */ - public void postExecute() throws SQLException { + public void postExecute() { OrmUpdateType ormUpdateType = ormUpdate.getOrmUpdateType(); String tableName = ormUpdate.getBaseTable(); diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestUpdateSql.java b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestUpdateSql.java index a9cb0817e..531416f51 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestUpdateSql.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/PersistRequestUpdateSql.java @@ -1,7 +1,5 @@ package com.avaje.ebeaninternal.server.core; -import java.sql.SQLException; - import com.avaje.ebean.SqlUpdate; import com.avaje.ebeaninternal.api.SpiEbeanServer; import com.avaje.ebeaninternal.api.SpiSqlUpdate; @@ -13,107 +11,108 @@ import com.avaje.ebeaninternal.server.persist.PersistExecute; */ public final class PersistRequestUpdateSql extends PersistRequest { - public enum SqlType { - SQL_UPDATE, SQL_DELETE, SQL_INSERT, SQL_UNKNOWN - } + public enum SqlType { + SQL_UPDATE, SQL_DELETE, SQL_INSERT, SQL_UNKNOWN + } - private final SpiSqlUpdate updateSql; + private final SpiSqlUpdate updateSql; - private int rowCount; + private int rowCount; - private String bindLog; + private String bindLog; - private SqlType sqlType; + private SqlType sqlType; - private String tableName; + private String tableName; - private String description; + private String description; - /** - * Create. - */ - public PersistRequestUpdateSql(SpiEbeanServer server, SqlUpdate updateSql, - SpiTransaction t, PersistExecute persistExecute) { - super(server, t, persistExecute); - this.type = Type.UPDATESQL; - this.updateSql = (SpiSqlUpdate)updateSql; - } + /** + * Create. + */ + public PersistRequestUpdateSql(SpiEbeanServer server, SqlUpdate updateSql, + SpiTransaction t, PersistExecute persistExecute) { - @Override - public int executeNow() { - return persistExecute.executeSqlUpdate(this); - } + super(server, t, persistExecute); + this.type = Type.UPDATESQL; + this.updateSql = (SpiSqlUpdate) updateSql; + } - @Override - public int executeOrQueue() { - return executeStatement(); - } + @Override + public int executeNow() { + return persistExecute.executeSqlUpdate(this); + } - /** - * Return the UpdateSql. - */ - public SpiSqlUpdate getUpdateSql() { - return updateSql; - } + @Override + public int executeOrQueue() { + return executeStatement(); + } - /** - * No concurrency checking so just note the rowCount. - */ - public void checkRowCount(int count) throws SQLException { - this.rowCount = count; - } + /** + * Return the UpdateSql. + */ + public SpiSqlUpdate getUpdateSql() { + return updateSql; + } - /** - * Not called for this type of request. - */ - public void setGeneratedKey(Object idValue) { - } + /** + * No concurrency checking so just note the rowCount. + */ + public void checkRowCount(int count) { + this.rowCount = count; + } - /** - * Specify the type of statement executed. Used to automatically register - * with the transaction event. - */ - public void setType(SqlType sqlType, String tableName, String description) { - this.sqlType = sqlType; - this.tableName = tableName; - this.description = description; - } + /** + * Not called for this type of request. + */ + public void setGeneratedKey(Object idValue) { + } - /** - * Set the bound values. - */ - public void setBindLog(String bindLog) { - this.bindLog = bindLog; - } + /** + * Specify the type of statement executed. Used to automatically register + * with the transaction event. + */ + public void setType(SqlType sqlType, String tableName, String description) { + this.sqlType = sqlType; + this.tableName = tableName; + this.description = description; + } - /** - * Perform post execute processing. - */ - public void postExecute() throws SQLException { + /** + * Set the bound values. + */ + public void setBindLog(String bindLog) { + this.bindLog = bindLog; + } - if (transaction.isLogSummary()) { - String m = description + " table[" + tableName + "] rows["+ rowCount + "] bind[" + bindLog + "]"; - transaction.logSummary(m); - } + /** + * Perform post execute processing. + */ + public void postExecute() { - if (updateSql.isAutoTableMod()) { - // add the modification info to the TransactionEvent - // this is used to invalidate cached objects etc - switch (sqlType) { - case SQL_INSERT: - transaction.getEvent().add(tableName, true, false, false); - break; - case SQL_UPDATE: - transaction.getEvent().add(tableName, false, true, false); - break; - case SQL_DELETE: - transaction.getEvent().add(tableName, false, false, true); - break; - - default: - break; - } - } - } + if (transaction.isLogSummary()) { + String m = description + " table[" + tableName + "] rows[" + rowCount + "] bind[" + bindLog + "]"; + transaction.logSummary(m); + } + + if (updateSql.isAutoTableMod()) { + // add the modification info to the TransactionEvent + // this is used to invalidate cached objects etc + switch (sqlType) { + case SQL_INSERT: + transaction.getEvent().add(tableName, true, false, false); + break; + case SQL_UPDATE: + transaction.getEvent().add(tableName, false, true, false); + break; + case SQL_DELETE: + transaction.getEvent().add(tableName, false, false, true); + break; + + default: + break; + } + } + } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchPostExecute.java b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchPostExecute.java index b0b8afe1b..776b7e8fd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/persist/BatchPostExecute.java +++ b/src/main/java/com/avaje/ebeaninternal/server/persist/BatchPostExecute.java @@ -16,7 +16,7 @@ public interface BatchPostExecute { * Check that the rowCount is correct for this execute. This is for * performing concurrency checking in batch execution. */ - void checkRowCount(int rowCount) throws SQLException; + void checkRowCount(int rowCount); /** * For inserts with generated keys. Otherwise not used. @@ -30,6 +30,6 @@ public interface BatchPostExecute { * and for beans resetting their 'loaded' status. *

*/ - void postExecute() throws SQLException; + void postExecute(); }