Interface EntityQueryModel


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:
  • Field Details

    • LIMIT

      static final PropertyValue<Integer> LIMIT
      Specifes a default limit() 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

      List<Entity> 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

      Returns:
      a EntityConnection.Select instance based on the current state of this EntityQueryModel
    • condition

      Returns:
      the EntityConditionModel instance used by this query model
    • conditionRequired

      State conditionRequired()
      Returns a State controlling 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 State controlling whether this query model requires a query condition
      See Also:
    • attributes

      Returns:
      the EntityQueryModel.SelectAttributes instance
    • limit

      Value<Integer> limit()
      Returns the Value controlling the maximum number of rows to fetch, a null value means all rows should be fetched
      Returns:
      the Value controlling the query limit
    • orderBy

      Value<OrderBy> 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 Value controlling the order by clause
      See Also:
    • referenceDepth

      Value<Integer> referenceDepth()
      Controls the reference depth used when querying, set to override the default. Setting this value to null reverts back to the default.
      Returns:
      the Value controlling the reference depth
    • referenceDepth

      Value<Integer> referenceDepth(ForeignKey foreignKey)
      Controls the reference depth for the given foreign key when querying, set to override the default. Setting this value to null reverts back to the default.
      Parameters:
      foreignKey - the foreign key
      Returns:
      the Value controlling the reference depth for the given foreign key
    • 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 the conditionRequired() State, which prevents a refresh as long as the ObservableState controlled via this method is disabled. The default ObservableState is simply TableConditionModel.enabled(). Override for a more fine-grained control, such as requiring a specific column condition to be enabled.
      Returns:
      the Value controlling the ObservableState specifying if enough conditions are enabled for a safe refresh
      See Also:
    • dataSource

      A Value controlling the data source. Use this to replace the default one.
      Returns:
      the Value controlling the data source
    • entityQueryModel

      static EntityQueryModel entityQueryModel(EntityConditionModel conditionModel)
      Parameters:
      conditionModel - the EntityConditionModel
      Returns:
      a new EntityQueryModel instance based on the given EntityConditionModel