Interface DataOperator<T extends BaseDataEntity<String>>

Type Parameters:
T - Data type inherited from 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.
      Parameters:
      id - Record 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
      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.

      Since 6.3.0, a call with no conditions (a null or zero-length whereConditions) is rejected with a DataAccessException instead of deleting every row of the table — this is a behavioral change with no migration period (COMPATIBILITY.md's security-fix channel); see 02-CONTEXT.md D-12.

      Parameters:
      whereConditions - Conditions
    • delById

      void delById(Object id)
      Delete data record by ID.
      Parameters:
      id - Record 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
    • 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.
      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.
      Parameters:
      entities - the entities to update
      Throws:
      IllegalAccessException - if field access fails