com.jpattern.orm.query.clause.OrmSetClause Maven / Gradle / Ivy
package com.jpattern.orm.query.clause;
import java.util.ArrayList;
import java.util.List;
import com.jpattern.orm.query.INameSolver;
import com.jpattern.orm.query.IQueryRoot;
import com.jpattern.orm.query.NullNameSolver;
import com.jpattern.orm.query.where.EqExpressionElement;
import com.jpattern.orm.query.where.ExpressionElement;
/**
*
* @author Francesco Cina
*
* 10/lug/2011
*/
public class OrmSetClause implements SetClause {
List elementList = new ArrayList();
private INameSolver nameSolver = new NullNameSolver();
private final T query;
public OrmSetClause(T query) {
this.query = query;
}
@Override
public SetClause eq(String property, Object value) {
final ExpressionElement expressionElement = new EqExpressionElement(property, value);
expressionElement.setNameSolver(nameSolver);
elementList.add(expressionElement);
return this;
}
@Override
public String renderSql() {
final StringBuilder StringBuilder = new StringBuilder();
renderSql(StringBuilder);
return StringBuilder.toString();
}
@Override
public void renderSql(StringBuilder StringBuilder) {
boolean first = true;
if (!elementList.isEmpty()) {
StringBuilder.append("SET ");
for (final ExpressionElement expressionElement : elementList) {
if (!first) {
StringBuilder.append(", ");
}
expressionElement.renderSql(StringBuilder);
first = false;
}
}
}
@Override
public void appendValues(List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy