use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class JdbcUtils method setPreparedStatementParameters.
public static void setPreparedStatementParameters(final PreparedStatement statement, final Query query) {
int index = 1;
for (final Object parameter : query.getParameters()) {
final JdbcFieldDefinition attribute = JdbcFieldDefinition.newFieldDefinition(parameter);
try {
index = attribute.setPreparedStatementValue(statement, index, parameter);
} catch (final SQLException e) {
throw new RuntimeException("Error setting value:" + parameter, e);
}
}
final Condition where = query.getWhereCondition();
if (!where.isEmpty()) {
where.appendParameters(index, statement);
}
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class JdbcUtils method appendWhere.
public static void appendWhere(final StringBuilder sql, final Query query) {
final Condition where = query.getWhereCondition();
if (!where.isEmpty()) {
sql.append(" WHERE ");
final RecordDefinition recordDefinition = query.getRecordDefinition();
if (recordDefinition == null) {
where.appendSql(query, null, sql);
} else {
final RecordStore recordStore = recordDefinition.getRecordStore();
where.appendSql(query, recordStore, sql);
}
}
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class OgrRecordStore method getWhereClause.
protected StringBuilder getWhereClause(final Query query) {
final StringBuilder whereClause = new StringBuilder();
final Condition whereCondition = query.getWhereCondition();
if (!whereCondition.isEmpty()) {
appendQueryValue(query, whereClause, whereCondition);
}
return whereClause;
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class QueryValueTest method testILike.
@SuppressWarnings("unchecked")
private void testILike() {
for (final Object like : Arrays.asList(10, "%10", "10%", "%10%", "%1%", "%0%")) {
final Condition trueCondition = Q.iLike(this.idField, like);
assertConditionTrue(trueCondition, this.record);
}
for (final String like : Arrays.asList("%Foobar", "fooBar%", "%foObar%", "%fOo%", "%bAr%", "%o%B%")) {
final Condition trueCondition = Q.iLike(this.nameAttribute, like);
assertConditionTrue(trueCondition, this.record);
}
for (final String like : Arrays.asList("%Foobar1", "Foobar1%", "%Foobar1%", "%Foo1%", "%Bar1%", "%a%b%")) {
final Condition falseCondition = Q.iLike(this.nameAttribute, like);
assertConditionFalse(falseCondition, this.record);
}
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class QueryValueTest method testLike.
@SuppressWarnings("unchecked")
private void testLike() {
for (final Object like : Arrays.asList(10, "%10", "10%", "%10%", "%1%", "%0%")) {
final Condition trueCondition = Q.like(this.idField, like);
assertConditionTrue(trueCondition, this.record);
}
for (final String like : Arrays.asList("%foobar", "foobar%", "%foobar%", "%foo%", "%bar%", "%o%b%")) {
final Condition trueCondition = Q.like(this.nameAttribute, like);
assertConditionTrue(trueCondition, this.record);
}
for (final String like : Arrays.asList("%Foobar", "Foobar%", "%Foobar%", "%Foo%", "%Bar%", "%O%b%")) {
final Condition falseCondition = Q.like(this.nameAttribute, like);
assertConditionFalse(falseCondition, this.record);
}
}
Aggregations