For the complete documentation index, see llms.txt. This page is also available as Markdown.

Predicate-Suffix Field

Predicate suffix fields are used to construct simple query conditions. The names of predicate suffix fields are defined through Attribute-Predicate Expressions (APE), i.e.:

{xR:xP(v)}\{x \in \mathcal{R} : xP(v)\}

This is abbreviated as xP, where x represents an attribute in relation R, P is from a predefined set of predicates, and v denotes the query parameter.

Predicate Suffix Mapping

DoytoQuery adopts the predicate suffix mapping method, which maps fields in the query object ending with predefined predicates to basic query conditions. Each basic query condition consists of a column name, a comparison operator, and a comparison value.

In a query object, the fields used to map basic query conditions are named in the format: column name + predicate alias. They are used to map the column name and comparison operator of the query condition, while the assigned value of the field serves as the comparison value for the query condition. In an instance of a query object, fields that have been assigned values are mapped to corresponding query conditions, which are then concatenated by the logical operator AND to form the query clause.

The following are two examples of suffix mapping:

UserQuery userQuery = UserQuery.builder().deleted(true).build();
List<UserEntity> users = userDataAccess.query(userQuery);
// SQL="SELECT id, name, score, memo, deleted FROM t_user WHERE deleted = ?" args="[true]"

UserQuery userQuery = UserQuery.builder().idIn(Arrays.asList(1, 4, 12)).deleted(true).build();
List<UserEntity> users = userDataAccess.query(userQuery);
// SQL="SELECT id, name, score, memo, deleted FROM t_user WHERE id IN (?, ?, ?) AND deleted = ?" args="[1 4 12 true]"

Predicate Suffix Table

The Predicate Suffix Table predefines the predicate suffixes supported in DoytoQuery and the query conditions to which they are mapped.

谓词后缀
字段名称
赋值
SQL查询条件

(EMPTY)

id

5

id = 5

Eq

idEq

5

id = 5

Not

idNot

5

id != 5

Ne

idNe

5

id <> 5

Gt

idGt

5

id > 5

Ge

idGe

5

id >= 5

Lt

idLt

5

id < 5

Le

idLe

5

id <= 5

NotIn

idNotIn

[1,2,3]

id NOT IN (1,2,3)

In

idIn

[1,2,3]

id IN (1,2,3)

Null

memoNull

true

memo IS NULL

Null

memoNull

false

memo IS NOT NULL

NotLike

nameNotLike

"arg"

name NOT LIKE '%arg%'

Like

nameLike

"arg"

name LIKE '%arg%'

NotStart

nameNotStart

"arg"

name NOT LIKE 'arg%'

Start

nameStart

"arg"

name LIKE 'arg%'

NotEnd

nameNotEnd

"arg"

name NOT LIKE '%arg'

End

nameEnd

"arg"

name LIKE '%arg'

NotContain

nameNotContain

"arg"

name NOT LIKE '%arg%’

Contain

nameContain

"arg"

name LIKE '%arg%’

Rx

nameRx

"arg\d"

name REGEXP 'arg\d’

Last updated