No effective change - code cleanup - remove unused for GenerateDmlRequest

This commit is contained in:
Robin Bygrave
2015-07-31 22:42:28 +12:00
parent c581fa27ab
commit db97d4576f
7 changed files with 8 additions and 129 deletions
@@ -17,8 +17,6 @@ import com.avaje.ebeaninternal.server.deploy.BeanProperty;
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
import com.avaje.ebeaninternal.server.persist.BatchControl;
import com.avaje.ebeaninternal.server.persist.PersistExecute;
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;
@@ -408,10 +406,6 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
return beanDescriptor.getId(entityBean);
}
public BeanDelta createDeltaBean() {
return new BeanDelta(beanDescriptor, getBeanId());
}
/**
* Return the parent bean for cascading save with unidirectional relationship.
*/
@@ -634,17 +628,6 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
return beanDescriptor.isUpdateChangesOnly() || !intercept.isFullyLoadedBean();
}
/**
* Create a GenerateDmlRequest used to generate the DML.
* <p>
* Will used changed properties or loaded properties depending on the
* BeanDescriptor.isUpdateChangesOnly() value.
* </p>
*/
public GenerateDmlRequest createGenerateDmlRequest(boolean emptyStringAsNull) {
return new GenerateDmlRequest(emptyStringAsNull, intercept, beanDescriptor.isUpdateChangesOnly());
}
/**
* Return true if the property should be included in the update.
*/
@@ -1,22 +0,0 @@
package com.avaje.ebeaninternal.server.lib.util;
/**
* A general exception that can be used for multiple purposes.
*/
public class GeneralException extends RuntimeException {
private static final long serialVersionUID = 5783084420007103280L;
public GeneralException(Exception cause) {
super(cause);
}
public GeneralException(String s, Exception cause) {
super(s, cause);
}
public GeneralException(String s) {
super(s);
}
}
@@ -1,23 +0,0 @@
package com.avaje.ebeaninternal.server.lib.util;
/**
* A general exception for invalid data.
*/
public class InvalidDataException extends RuntimeException
{
static final long serialVersionUID = 7061559938704539846L;
public InvalidDataException(Exception cause) {
super(cause);
}
public InvalidDataException(String s, Exception cause) {
super(s, cause);
}
public InvalidDataException(String s) {
super(s);
}
}
@@ -91,7 +91,7 @@ public final class DeleteMeta {
// delete ... where bcol=? and bc1=? and bc2 is null and ...
GenerateDmlRequest request = new GenerateDmlRequest(emptyStringAsNull);
GenerateDmlRequest request = new GenerateDmlRequest();
request.append("delete from ").append(tableName);
request.append(" where ");
@@ -1,8 +1,5 @@
package com.avaje.ebeaninternal.server.persist.dml;
import com.avaje.ebean.bean.EntityBeanIntercept;
import com.avaje.ebeaninternal.server.deploy.BeanProperty;
/**
* Helper to support the generation of DML statements.
*/
@@ -10,13 +7,8 @@ public class GenerateDmlRequest {
private static final String IS_NULL = " is null";
private final boolean emptyStringAsNull;
private final StringBuilder sb = new StringBuilder(100);
private final EntityBeanIntercept ebi;
private final boolean changesOnly;
private StringBuilder insertBindBuffer;
private String prefix;
@@ -29,17 +21,7 @@ public class GenerateDmlRequest {
/**
* Create from a PersistRequestBean.
*/
public GenerateDmlRequest(boolean emptyStringAsNull, EntityBeanIntercept ebi, boolean changesOnly) {//, Object oldValues) {
this.emptyStringAsNull = emptyStringAsNull;
this.ebi = ebi;
this.changesOnly = changesOnly;
}
/**
* Create for generating standard all properties DML/SQL.
*/
public GenerateDmlRequest(boolean emptyStringAsNull) {
this(emptyStringAsNull, null, false);
public GenerateDmlRequest() {
}
public GenerateDmlRequest append(String s) {
@@ -47,31 +29,6 @@ public class GenerateDmlRequest {
return this;
}
public boolean isDbNull(Object v) {
return v == null || (emptyStringAsNull && (v instanceof String) && ((String) v).length() == 0);
}
/**
* Return true if this property should be included in the set clause.
*/
public boolean isIncluded(BeanProperty prop) {
if (ebi == null) {
return true;
}
if (changesOnly) {
return ebi.isDirtyProperty(prop.getPropertyIndex());
} else {
return ebi.isLoadedProperty(prop.getPropertyIndex());
}
}
/**
* Return true if this property should be included in the where clause.
*/
public boolean isIncludedWhere(BeanProperty prop) {
return ebi == null || ebi.isLoadedProperty(prop.getPropertyIndex());
}
public void appendColumnIsNull(String column) {
appendColumn(column, IS_NULL);
}
@@ -82,11 +39,7 @@ public class GenerateDmlRequest {
}
public void appendColumn(String column, String bind) {
appendColumn(column, "", bind);
}
public void appendColumn(String column, String expr, String bind) {
++bindColumnCount;
sb.append(prefix);
@@ -120,11 +73,6 @@ public class GenerateDmlRequest {
return sb.toString();
}
public void setWhereMode() {
this.prefix = " and ";
this.prefix2 = " and ";
}
public void setWhereIdMode() {
this.prefix = "";
this.prefix2 = " and ";
@@ -165,7 +165,7 @@ public final class InsertMeta {
private String genSql(boolean nullId) {
GenerateDmlRequest request = new GenerateDmlRequest(emptyStringToNull, null, true);
GenerateDmlRequest request = new GenerateDmlRequest();
request.setInsertSetMode();
request.append("insert into ").append(tableName);
@@ -39,8 +39,8 @@ public final class UpdateMeta {
this.id = id;
this.version = version;
String sqlNone = genSql(ConcurrencyMode.NONE, null, set);
String sqlVersion = genSql(ConcurrencyMode.VERSION, null, set);
String sqlNone = genSql(ConcurrencyMode.NONE, set);
String sqlVersion = genSql(ConcurrencyMode.VERSION, set);
this.modeNoneUpdatePlan = new UpdatePlan(ConcurrencyMode.NONE, sqlNone, set);
this.modeVersionUpdatePlan = new UpdatePlan(ConcurrencyMode.VERSION, sqlVersion, set);
@@ -142,7 +142,7 @@ public final class UpdateMeta {
ConcurrencyMode mode = persistRequest.determineConcurrencyMode();
// build the SQL for this update statement
String sql = genSql(mode, persistRequest, bindableList);
String sql = genSql(mode, bindableList);
updatePlan = new UpdatePlan(key, mode, sql, bindableList);
@@ -152,18 +152,11 @@ public final class UpdateMeta {
return updatePlan;
}
private String genSql(ConcurrencyMode conMode, PersistRequestBean<?> persistRequest, BindableList bindableList) {
private String genSql(ConcurrencyMode conMode, BindableList bindableList) {
// update set col0=?, col1=?, col2=? where bcol=? and bc1=? and bc2=?
GenerateDmlRequest request;
if (persistRequest == null) {
// For generation of None and Version DML/SQL
request = new GenerateDmlRequest(emptyStringAsNull);
} else {
request = persistRequest.createGenerateDmlRequest(emptyStringAsNull);
}
GenerateDmlRequest request = new GenerateDmlRequest();
request.append("update ").append(tableName).append(" set ");
request.setUpdateSetMode();