Interface Query<T extends BaseDataEntity<String>>
- Type Parameters:
T- the entity type
- All Known Implementing Classes:
QueryImpl
public interface Query<T extends BaseDataEntity<String>>
Fluent query builder for data entities.
Provides a readable DSL for filtering, ordering, and paginating results.
数据实体的流式查询构建器。提供可读的DSL用于过滤、排序和分页。
Usage example:
HomeEntity home = plugin.getDataOperator(HomeEntity.class)
.query()
.where("playerId").eq(uuid)
.and("name").eq("base")
.first();
-
Method Summary
Modifier and TypeMethodDescriptionAdd an AND condition on a column.longcount()Count the number of matching results.intdelete()Delete all matching results and return the count of deleted rows.Equal to.booleanexists()Check if any results match the query.first()Execute the query and return the first matching result, or null if none.Greater than.Greater than or equal to.in(Collection<?> values) Value is in the given collection.SQL LIKE pattern matching.limit(int count) Limit the number of results.list()Execute the query and return all matching results.Less than.Less than or equal to.Not equal to.offset(int start) Skip a number of results.Order results by column ascending.orderByDesc(String column) Order results by column descending.Start a where condition on a column.
-
Method Details
-
where
Start a where condition on a column.开始一个列的查询条件。
- Parameters:
column- the column name- Returns:
- this query for chaining
-
and
Add an AND condition on a column.添加一个AND条件。
- Parameters:
column- the column name- Returns:
- this query for chaining
-
eq
Equal to.等于。
- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
ne
Not equal to.不等于。
- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
gt
Greater than.大于。
- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
lt
Less than.小于。
- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
gte
Greater than or equal to.大于等于。
- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
lte
Less than or equal to.小于等于。
- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
like
SQL LIKE pattern matching.SQL LIKE模式匹配。
- Parameters:
pattern- the LIKE pattern (use % for wildcard)- Returns:
- this query for chaining
-
in
Value is in the given collection.值在给定集合中。
- Parameters:
values- the collection of allowed values- Returns:
- this query for chaining
-
orderBy
Order results by column ascending.按列升序排列结果。
- Parameters:
column- the column to order by- Returns:
- this query for chaining
-
orderByDesc
Order results by column descending.按列降序排列结果。
- Parameters:
column- the column to order by- Returns:
- this query for chaining
-
limit
Limit the number of results.限制结果数量。
- Parameters:
count- the maximum number of results- Returns:
- this query for chaining
-
offset
Skip a number of results.跳过指定数量的结果。
- Parameters:
start- the number of results to skip- Returns:
- this query for chaining
-
list
Execute the query and return all matching results.执行查询并返回所有匹配结果。
- Returns:
- list of matching entities
-
first
T first()Execute the query and return the first matching result, or null if none.执行查询并返回第一个匹配结果,如果没有则返回null。
- Returns:
- the first matching entity, or null
-
exists
boolean exists()Check if any results match the query.检查是否有匹配查询的结果。
- Returns:
- true if at least one result exists
-
count
long count()Count the number of matching results.计算匹配结果的数量。
- Returns:
- the count of matching results
-
delete
int delete()Delete all matching results and return the count of deleted rows.删除所有匹配结果并返回已删除的行数。
- Returns:
- the count of deleted rows
-