net.hasor.db.jdbc.lambda.Compare Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hasor-db Show documentation
Show all versions of hasor-db Show documentation
the hasor DataBase project.
/*
* Copyright 2002-2005 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.hasor.db.jdbc.lambda;
import net.hasor.utils.reflect.SFunction;
import java.util.Collection;
import java.util.function.Consumer;
/**
* 动态拼条件。
* 主动调用or表示紧接着下一个方法不是用and连接!(不调用or则默认为使用and连接)
* @version : 2020-10-31
* @author 赵永春 ([email protected])
*/
public interface Compare {
/** 等于条件 查询,类似:'or ...' */
public R or();
/** 等于条件 查询,类似:'or ...' */
public R and();
/** 括号方式嵌套一组查询条件,与现有条件为并且关系。类似:'and ( ...where... )' */
public default R and(Consumer> lambda) {
this.and();
return this.nested(lambda);
}
/** 括号方式嵌套一组查询条件,与现有条件为或关系。类似:'or ( ...where... )' */
public default R or(Consumer> lambda) {
this.or();
return this.nested(lambda);
}
/** 括号方式嵌套一组查询条件 */
public R nested(Consumer> lambda);
/** 等于条件 查询,类似:'col = ?' */
public R eq(SFunction property, Object value);
/** 不等于条件 查询,类似:'col <> ?' */
public R ne(SFunction property, Object value);
/** 大于条件 查询,类似:'col > ?' */
public R gt(SFunction property, Object value);
/** 大于等于条件 查询,类似:'col >= ?' */
public R ge(SFunction property, Object value);
/** 小于条件 查询,类似:'col < ?' */
public R lt(SFunction property, Object value);
/** 小于等于条件 查询,类似:'col <= ?' */
public R le(SFunction property, Object value);
/** like 查询,类似:'col like CONCAT('%', ?, '%')' */
public R like(SFunction property, Object value);
/** not like 查询,类似:'col not like CONCAT('%', ?, '%')' */
public R notLike(SFunction property, Object value);
/** like 查询,类似:'col like CONCAT(?, '%')' */
public R likeRight(SFunction property, Object value);
/** not like 查询,类似:'col not like CONCAT(?, '%')' */
public R notLikeRight(SFunction property, Object value);
/** like 查询,类似:'col like CONCAT('%', ?)' */
public R likeLeft(SFunction property, Object value);
/** not like 查询,类似:'col not like CONCAT('%', ?)' */
public R notLikeLeft(SFunction property, Object value);
/** is null 查询,类似:'col is null' */
public R isNull(SFunction property);
/** not null 查询,类似:'col is not null' */
public R isNotNull(SFunction property);
/** in 查询,类似:'col in (?,?,?)' */
public R in(SFunction property, Collection> value);
/** not in 查询,类似:'col not in (?,?,?)' */
public R notIn(SFunction property, Collection> value);
/** between 语句,类似:'col between ? and ?' */
public R between(SFunction property, Object value1, Object value2);
/** not between 语句,类似:'col not between ? and ?' */
public R notBetween(SFunction property, Object value1, Object value2);
// /** in 子查询,类似:'col in (LambdaQuery)' */
// public R andInLambda(SFunction property, CompareBuilder subLambda);
// /** in 子查询,类似:'or col in (LambdaQuery)' */
// public R orInLambda(SFunction property, CompareBuilder subLambda);
// /** not in 子查询,类似:'col not in (LambdaQuery)' */
// public R andNotInLambda(SFunction property, CompareBuilder subLambda);
// /** not in 子查询,类似:'or col not in (LambdaQuery)' */
// public R orNotInLambda(SFunction property, CompareBuilder subLambda);
// /** in SQL 子查询,类似:'col in (subQuery)' */
// public R andInSql(SFunction property, String subQuery, Object... subArgs);
// /** in SQL 子查询,类似:'or col in (subQuery)' */
// public R orInSql(SFunction property, String subQuery, Object... subArgs);
// /** not in SQL 子查询,类似:'col not in (subQuery)' */
// public R andNotInSql(SFunction property, String subQuery, Object... subArgs);
// /** not in SQL 子查询,类似:'or col not in (subQuery)' */
// public R orNotInSql(SFunction property, String subQuery, Object... subArgs);
/**
* 拼接 sql
* !! 会有 sql 注入风险 !!
* 例1: apply("id = 1")
* 例2: apply("date_format(dateColumn,'%Y-%m-%d') = '2008-08-08'")
* 例3: apply("date_format(dateColumn,'%Y-%m-%d') = {0}", LocalDate.now())
*/
public R apply(String sqlString, Object... args);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy