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 Details

    • where

      Query<T> where(String column)
      Start a where condition on a column.

      开始一个列的查询条件。

      Parameters:
      column - the column name
      Returns:
      this query for chaining
    • and

      Query<T> and(String column)
      Add an AND condition on a column.

      添加一个AND条件。

      Parameters:
      column - the column name
      Returns:
      this query for chaining
    • eq

      Query<T> eq(Object value)
      Equal to.

      等于。

      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • ne

      Query<T> ne(Object value)
      Not equal to.

      不等于。

      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • gt

      Query<T> gt(Object value)
      Greater than.

      大于。

      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • lt

      Query<T> lt(Object value)
      Less than.

      小于。

      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • gte

      Query<T> gte(Object value)
      Greater than or equal to.

      大于等于。

      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • lte

      Query<T> lte(Object value)
      Less than or equal to.

      小于等于。

      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • like

      Query<T> like(String pattern)
      SQL LIKE pattern matching.

      SQL LIKE模式匹配。

      Parameters:
      pattern - the LIKE pattern (use % for wildcard)
      Returns:
      this query for chaining
    • in

      Query<T> in(Collection<?> values)
      Value is in the given collection.

      值在给定集合中。

      Parameters:
      values - the collection of allowed values
      Returns:
      this query for chaining
    • orderBy

      Query<T> orderBy(String column)
      Order results by column ascending.

      按列升序排列结果。

      Parameters:
      column - the column to order by
      Returns:
      this query for chaining
    • orderByDesc

      Query<T> orderByDesc(String column)
      Order results by column descending.

      按列降序排列结果。

      Parameters:
      column - the column to order by
      Returns:
      this query for chaining
    • limit

      Query<T> limit(int count)
      Limit the number of results.

      限制结果数量。

      Parameters:
      count - the maximum number of results
      Returns:
      this query for chaining
    • offset

      Query<T> offset(int start)
      Skip a number of results.

      跳过指定数量的结果。

      Parameters:
      start - the number of results to skip
      Returns:
      this query for chaining
    • list

      List<T> 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