Class QueryImpl<T extends BaseDataEntity<String>>
java.lang.Object
com.ultikits.ultitools.interfaces.impl.data.QueryImpl<T>
- Type Parameters:
T- the entity type
- All Implemented Interfaces:
Query<T>
Default implementation of
Query that wraps a DataOperator.
Equality conditions are delegated to the underlying DataOperator's getAll() method. Non-equality conditions (ne, gt, lt, gte, lte, like, in) are applied as in-memory filters. Ordering, limit, and offset are applied as in-memory post-processing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceSimple functional interface for in-memory filtering (Java 8 compatible). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate final List<WhereCondition> private final List<QueryImpl.Predicate<T>> private intprivate intprivate final DataOperator<T> private Stringprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an AND condition on a column.private intcompareField(T entity, String columnName, Object refValue) Compare an entity's field value against a reference value.private intcompareValues(Object a, Object b) Compare two values.longcount()Count the number of matching results.intdelete()Deletes every row this query matches and returns the number of rows the backend actually removed (#521).private intEqual to.private static BigDecimalexactFiniteValue(Number value) The exact mathematical value of a supported finite number, or null for the legacy path.booleanexists()Check if any results match the query.first()Execute the query and return the first matching result, or null if none.private ObjectgetFieldValue(T entity, String columnName) Get a field value from an entity by column name.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.
-
Field Details
-
operator
-
eqConditions
-
filters
-
currentColumn
-
orderByColumn
-
orderDesc
private boolean orderDesc -
limitCount
private int limitCount -
offsetStart
private int offsetStart
-
-
Constructor Details
-
QueryImpl
-
-
Method Details
-
where
-
and
-
eq
-
ne
-
gt
-
lt
-
gte
-
lte
-
like
-
in
-
orderBy
-
orderByDesc
Description copied from interface:QueryOrder results by column descending.- Specified by:
orderByDescin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
column- the column to order by- Returns:
- this query for chaining
-
limit
-
offset
-
list
-
first
-
exists
-
count
-
delete
public int delete()Deletes every row this query matches and returns the number of rows the backend actually removed (#521).Before 6.3.0 this returned the number of rows the query matched, and a matched row with a
nullid was skipped yet still counted, so the value could report rows removed that were not. Now:- the count comes from the backend: the framework's operators report each delete's
affected rows through
RowCountingDelete, so a matched row that another writer removed first is not counted. A third-party operator that does not implement it cannot report what itsdelByIdremoved, so a row is counted only if it existed immediately before that call and is gone after it; a row another writer removes during that one call is the only case this can still count; - a matched row with a
nullid cannot be addressed by any delete, so it is refused with aDataAccessExceptionnaming the entity type before anything is deleted, instead of being skipped silently.
- Specified by:
deletein interfaceQuery<T extends BaseDataEntity<String>>- Returns:
- the number of rows removed
- Throws:
DataAccessException- if a matched row has anullid; nothing is deleted then
- the count comes from the backend: the framework's operators report each delete's
affected rows through
-
deleteOne
-
getFieldValue
-
compareField
-
compareValues
-
exactFiniteValue
The exact mathematical value of a supported finite number, or null for the legacy path.
-