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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoiddel(WhereCondition... whereConditions) Delete data record by conditions.voidDelete data record by ID.booleanexist(WhereCondition... whereConditions) Check if the data record exists.booleanCheck if the data record exists.getAll()Get all data record.getAll(WhereCondition... whereConditions) Get all data record by conditions.Get data record by ID.getLike(String column, String value, DataOperator.LikeType likeType) Fuzzy QueryvoidInsert data record.default voidInsert multiple entities atomically.page(int page, int size, WhereCondition... whereConditions) Get data record by page.query()Returns a new fluent query builder for this data operator.default voidtransaction(Runnable action) Execute operations within a transaction (void variant).default <R> Rtransaction(Callable<R> action) Execute operations within a transaction.voidUpdate one field of one record.voidUpdate data record by object.default voidUpdate multiple entities atomically.
-
Method Details
-
exist
Check if the data record exists.- Parameters:
object- Data record entity- Returns:
- Whether the record exists
-
exist
Check if the data record exists.- Parameters:
whereConditions- Conditions- Returns:
- Whether the record exists
-
getById
Get data record by ID.- Parameters:
id- Record ID- Returns:
- Data record
-
getAll
Get all data record.- Returns:
- Data record list
-
getAll
Get all data record by conditions.- Parameters:
whereConditions- Conditions- Returns:
- Data record list
-
getLike
Fuzzy Query- Parameters:
column- Column namevalue- Query valuelikeType- Like type- Returns:
- Data record list
-
page
Get data record by page.- Parameters:
page- Page numbersize- Page sizewhereConditions- Conditions- Returns:
- Data record list
-
insert
Insert data record.- Parameters:
obj- Data record
-
del
Delete data record by conditions.Since 6.3.0, a call with no conditions (a
nullor zero-lengthwhereConditions) is rejected with aDataAccessExceptioninstead 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
Delete data record by ID.- Parameters:
id- Record ID
-
update
Update one field of one record.- Parameters:
column- Column namevalue- New valueid- Record ID
-
update
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
Returns a new fluent query builder for this data operator.- Returns:
- a new Query builder
-
transaction
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
Execute operations within a transaction (void variant).- Parameters:
action- the operations to execute
-
insertAll
Insert multiple entities atomically. Uses JDBC batch for SQL backends.- Parameters:
entities- the entities to insert
-
updateAll
Update multiple entities atomically. Uses JDBC batch for SQL backends.- Parameters:
entities- the entities to update- Throws:
IllegalAccessException- if field access fails
-