public interface EntityQueryModel
Provides entities based on query conditions.
The default data source can be overridden by using
dataSource().
tableModel.query().dataSource().set(query -> {
EntityConnection connection = query.connectionProvider().connection();
return connection.select(Employee.NAME.equalTo("John"));
});
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceManages the attributes to include and exclude when querying. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<Integer> Specifes a defaultlimit()to set for query models. -
Method Summary
Modifier and TypeMethodDescriptionIt can be necessary to prevent the user from selecting too much data, when working with a large dataset.Returns aStatecontrolling whether this query model should query all underlying entities when no query condition has been set.AValuecontrolling the data source.static EntityQueryModelentityQueryModel(EntityConditionModel conditionModel) limit()Returns theValuecontrolling the maximum number of rows to fetch, a null value means all rows should be fetchedorderBy()Controls the order by clause to use when selecting the data for this model.query()Performs a query and returns the result.select()
-
Field Details
-
LIMIT
Specifes a defaultlimit()to set for query models.- Value type: Integer
- Default value: null
-
-
Method Details
-
entityType
EntityType entityType()- Returns:
- the type of the entity this query model is based on
-
connectionProvider
EntityConnectionProvider connectionProvider()- Returns:
- the connection provider
-
query
Performs a query and returns the result. Note that if a query condition is required (conditionRequired()) and the condition is not enabled (conditionEnabled()) an empty list is returned.- Returns:
- entities selected from the database according to the query condition.
- See Also:
-
select
EntityConnection.Select select()- Returns:
- a
EntityConnection.Selectinstance based on the current state of thisEntityQueryModel
-
condition
EntityConditionModel condition()- Returns:
- the
EntityConditionModelinstance used by this query model
-
conditionRequired
State conditionRequired()Returns aStatecontrolling whether this query model should query all underlying entities when no query condition has been set. Setting this value to 'true' prevents all rows from being fetched by accident, when no condition has been set, which is recommended for queries with a large underlying dataset.- Returns:
- a
Statecontrolling whether this query model requires a query condition - See Also:
-
attributes
EntityQueryModel.SelectAttributes attributes()- Returns:
- the
EntityQueryModel.SelectAttributesinstance
-
limit
Returns theValuecontrolling the maximum number of rows to fetch, a null value means all rows should be fetched- Returns:
- the
Valuecontrolling the query limit
-
orderBy
Controls the order by clause to use when selecting the data for this model. Setting this value to null reverts back to the default order by for the underlying entity, if one has been specified- Returns:
- the
Valuecontrolling the order by clause - See Also:
-
conditionEnabled
Value<ObservableState> conditionEnabled()It can be necessary to prevent the user from selecting too much data, when working with a large dataset. This can be done by enabling theconditionRequired()State, which prevents a refresh as long as theObservableStatecontrolled via this method is disabled. The defaultObservableStateis simplyTableConditionModel.enabled(). Override for a more fine-grained control, such as requiring a specific column condition to be enabled.- Returns:
- the
Valuecontrolling theObservableStatespecifying if enough conditions are enabled for a safe refresh - See Also:
-
dataSource
Value<Function<EntityQueryModel,List<Entity>>> dataSource()AValuecontrolling the data source. Use this to replace the default one.- Returns:
- the
Valuecontrolling the data source
-
entityQueryModel
- Parameters:
conditionModel- theEntityConditionModel- Returns:
- a new
EntityQueryModelinstance based on the givenEntityConditionModel
-