Package io.ebean

Interface Filter<T>

  • Type Parameters:
    T - the entity bean type

    public interface Filter<T>
    Provides support for filtering and sorting lists of entities without going back to the database.

    That is, it uses local in-memory sorting and filtering of a list of entity beans. It is not used in a Database query or invoke a Database query.

    You can optionally specify a sortByClause and if so, the sort will always execute prior to the filter expressions. You can specify any number of filter expressions and they are effectively joined by logical "AND".

    The result of the filter method will leave the original list unmodified and return a new List instance.

     // get a list of entities (query execution statistics in this case)
     List<MetaQueryStatistic> list =
     long nowMinus24Hrs = System.currentTimeMillis() - 24 * (1000 * 60 * 60);
     // sort and filter the list returning a filtered list...
     List<MetaQueryStatistic> filteredList =
             .sort("avgTimeMicros desc")
             .gt("executionCount", 0)
             .gt("lastQueryTime", nowMinus24Hrs)
             .eq("autoTuned", true)

    The propertyNames can traverse the object graph (e.g. by using dot notation. If any point during the object graph traversal to get a property value is null then null is returned.

     // examples of property names that
     // ... will traverse the object graph
     // ... where customer is a property of our bean


     // get a list of entities (query execution statistics)
     List<Order> orders =
     // Apply a filter...
     List<Order> filteredOrders =
             .startsWith("", "Rob")
             .eq("", "Auckland")