Interface DataOperator<T extends BaseDataEntity<String>>

Type Parameters:
T - 数据类型,继承自BaseDataEntity
All Known Implementing Classes:
AbstractRelationalDataOperator, MysqlDataOperator, SimpleJsonDataOperator, SQLiteDataOperator

public interface DataOperator<T extends BaseDataEntity<String>>
Data operation interface.

数据操作接口

  • Method Details

    • exist

      boolean exist(T object)
      Check if the data record exists.

      查询记录数据是否存在。

      Parameters:
      object - Data record entity
      数据记录实体
      Returns:
      Whether the record exists
      记录是否存在
    • exist

      boolean exist(WhereCondition... whereConditions)
      Check if the data record exists.

      使用条件查询记录是否存在

      Parameters:
      whereConditions - Conditions
      条件参数
      Returns:
      Whether the record exists
      记录是否存在
    • getById

      T getById(Object id)
      Get data record by ID.

      使用ID获取记录

      Parameters:
      id - Record ID
      记录ID
      Returns:
      Data record
      数据记录
    • getAll

      List<T> getAll()
      Get all data record.

      查询所有记录

      Returns:
      Data record list
      数据记录列表
    • getAll

      List<T> getAll(WhereCondition... whereConditions)
      Get all data record by conditions.

      查询所有符合条件的记录

      Parameters:
      whereConditions - Conditions
      条件参数
      Returns:
      Data record list
      数据记录列表
    • getLike

      List<T> getLike(String column, String value, DataOperator.LikeType likeType)
      Fuzzy Query

      模糊查询

      Parameters:
      column - Column name
      列名
      value - Query value
      查询值
      likeType - Like type
      模糊查询类型
      DataOperator.LikeType
      Returns:
      Data record list
      数据记录列表
    • page

      List<T> page(int page, int size, WhereCondition... whereConditions)
      Get data record by page.

      分页查询

      Parameters:
      page - Page number
      页码
      size - Page size
      页大小
      whereConditions - Conditions
      条件参数
      Returns:
      Data record list
      数据记录列表
    • insert

      void insert(T obj)
      Insert data record.

      新增记录

      Parameters:
      obj - Data record
      数据记录
    • del

      void del(WhereCondition... whereConditions)
      Delete data record by conditions.

      按照条件删除记录

      Parameters:
      whereConditions - Conditions
      条件参数
    • delById

      void delById(Object id)
      Delete data record by ID.

      按照ID删除记录

      Parameters:
      id - Record ID
      记录ID
    • update

      void update(String column, Object value, Object id)
      Update one field of one record.

      更新某个记录的某个值

      Parameters:
      column - Column name
      列名
      value - New value
      新值
      id - Record ID
      记录ID
    • update

      void update(T obj) throws IllegalAccessException
      Update data record by object. It will not update the fields that the incoming entity does not have.

      使用实体更新记录。不会更新传入实体没有的字段。

      Parameters:
      obj - Data record
      数据记录
      Throws:
      IllegalAccessException - Please referIllegalAccessException
    • query

      default Query<T> query()
      Returns a new fluent query builder for this data operator.

      返回此数据操作器的新流式查询构建器。

      Returns:
      a new Query builder
    • transaction

      default <R> R transaction(Callable<R> action) throws Exception
      Execute operations within a transaction. All operations commit together or roll back on exception. For SQL backends, uses database transactions. For JSON, uses snapshot-based rollback.

      在事务中执行操作。所有操作一起提交或在异常时回滚。

      Type Parameters:
      R - the return type
      Parameters:
      action - the operations to execute
      Returns:
      the result of the action
      Throws:
      Exception - if the action fails
    • transaction

      default void transaction(Runnable action)
      Execute operations within a transaction (void variant).

      在事务中执行操作(无返回值)。

      Parameters:
      action - the operations to execute
    • insertAll

      default void insertAll(List<T> entities)
      Insert multiple entities atomically. Uses JDBC batch for SQL backends.

      批量原子插入。SQL后端使用JDBC批处理。

      Parameters:
      entities - the entities to insert
    • updateAll

      default void updateAll(List<T> entities) throws IllegalAccessException
      Update multiple entities atomically. Uses JDBC batch for SQL backends.

      批量原子更新。SQL后端使用JDBC批处理。

      Parameters:
      entities - the entities to update
      Throws:
      IllegalAccessException - if field access fails