com.github.antelopeframework.mybatis.criterion.SQLCriterion Maven / Gradle / Ivy
package com.github.antelopeframework.mybatis.criterion;
/**
* A SQL fragment. The string {alias} will be replaced by the alias of the root
* entity.
*
* @author yangzhi.yzh
*/
public class SQLCriterion implements Criterion {
private static final long serialVersionUID = 1L;
private final String sql;
private final TypedValue[] typedValues;
protected SQLCriterion(String sql, Object[] values, int[] sqlTypes) {
this.sql = sql;
this.typedValues = new TypedValue[values.length];
for (int i = 0; i < typedValues.length; i++) {
typedValues[i] = new TypedValue(sqlTypes[i], values[i]);
}
}
protected SQLCriterion(String sql, Object value, int sqlType) {
this.sql = sql;
this.typedValues = new TypedValue[] { new TypedValue(sqlType, value) };
}
protected SQLCriterion(String sql) {
this.sql = sql;
this.typedValues = new TypedValue[0];
}
@Override
public String toSqlString(CriteriaQuery criteriaQuery) {
return sql;
}
@Override
public TypedValue[] getTypedValues(CriteriaQuery criteriaQuery) {
return typedValues;
}
@Override
public String toString() {
return sql;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy