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

Custom Condition Field

Usage Scenario

When encountering SQL statements that cannot be supported by existing field mapping methods, the annotation @QueryField can be used to define custom SQL statements as a temporary solution.

Annotation Definition

QueryField.java
@Target(FIELD)
@Retention(RUNTIME)
public @interface QueryField {
    String and();
}

When the value of the annotated field satisfies the filter condition, the conditional statement defined in the and variable will be appended to the SQL statement.

Code Example

Business Code:

public class TestQuery extends PageQuery {
    @QueryField(and = "(username = ? OR email = ? OR mobile = ?)")
    private String account;
}

Unit Test:

The query condition defined by the @QueryField annotation on the account field of TestQuery is appended verbatim to the WHERE clause. Because the query condition contains three placeholders, the value "test" of account is also added to the argList three times.

Last updated