Skip to main content

4.1 Base Usage

The following three ways of writing are equivalent

Use multiple filters

String name = ...Omitted...;
int edition = ...Omitted...;

BookTable table = BookTable.$;
List<Book> books = sqlClient
.createQuery(table)
.where(table.name().ilike(name))
.where(table.edition().eq(edition))
.select(table)
.execute();

Filter with multiple arguments

String name = ...Omitted...;
int edition = ...Omitted...;

BookTable table = BookTable.$;
List<Book> books = sqlClient
.createQuery(table)
.where(
table.name().ilike(name),
table.edition().eq(edition)
)
.select(table)
.execute();

Logic And

String name = ...Omitted...;
int edition = ...Omitted...;

BookTable table = BookTable.$;
List<Book> books = sqlClient
.createQuery(table)
.where(
Predicate.and(
table.name().ilike(name),
table.edition().eq(edition)
)
)
.select(table)
.execute();

Suggestion

The above three ways are completely equivalent. However, there is no doubt that the first one is the easiest, so it is recommended.