}
for (Criterion criterion : group) {
if (criterion instanceof Group) {
addGroupParams(query, (Group) criterion, names);
} else {
Comparison comparison = (Comparison) criterion;
if (comparison.isObjectIdentity()) {
continue;
}
String name = CriteriaUtils.ditchDot(comparison.getName());
name = CriteriaUtils.ensureUnique(names, name);
if (comparison.getValue() != null) {
final String sOperator = comparison.getOperator()
.getOperator();
if (!"like".equalsIgnoreCase(sOperator)) {
if (comparison instanceof Between) {
Between between = (Between) comparison;
query.setParameter(name + "_1", comparison
.getValue());
query
.setParameter(name + "_2", between
.getValue2());
} else if (comparison instanceof VerifiedBetween) {
VerifiedBetween between = (VerifiedBetween) comparison;
query.setParameter(name + "_1", comparison
.getValue());
query
.setParameter(name + "_2", between
.getValue2());
} else {
query.setParameter(name, comparison.getValue());
}
} else {
Operator operator = comparison.getOperator();
StringBuilder value = new StringBuilder(50);
if (operator == Operator.LIKE) {
value.append(comparison.getValue());
} else if (operator == Operator.LIKE_CONTAINS) {
value.append("%").append(comparison.getValue())
.append("%");
} else if (operator == Operator.LIKE_END) {
value.append("%").append(comparison.getValue());
} else if (operator == Operator.LIKE_START) {
value.append(comparison.getValue()).append("%");
}
if (logger.isDebugEnabled()) {
logger.debug("parameters");
logger
.debug("value name = "
+ comparison.getName());
logger.debug("value value = " + value);
}
query.setParameter(name, value.toString());
}
}