mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
No effective change - code cleanup - remove unused for GenerateDmlRequest
This commit is contained in:
1 parent
c581fa27ab
commit
db97d4576f
7 files changed
+8
-129
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user