- Type Parameters:
T
- the entity bean type
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 =
DB.find(MetaQueryStatistic.class).findList();
long nowMinus24Hrs = System.currentTimeMillis() - 24 * (1000 * 60 * 60);
// sort and filter the list returning a filtered list...
List<MetaQueryStatistic> filteredList =
DB.filter(MetaQueryStatistic.class)
.sort("avgTimeMicros desc")
.gt("executionCount", 0)
.gt("lastQueryTime", nowMinus24Hrs)
.eq("autoTuned", true)
.maxRows(10)
.filter(list);
The propertyNames can traverse the object graph (e.g. customer.name) 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
customer.name
customer.shippingAddress.city
// get a list of entities (query execution statistics)
List<Order> orders =
DB.find(Order.class).findList();
// Apply a filter...
List<Order> filteredOrders =
DB.filter(Order.class)
.startsWith("customer.name", "Rob")
.eq("customer.shippingAddress.city", "Auckland")
.filter(orders);
-
Method Summary
Modifier and TypeMethodDescriptionBetween - property between the two given values.Contains - property contains the string "value".Ends With.Equal To - property equal to the given value.Apply the filter to the list returning a new list of the matching elements in the sorted order.Greater Than or Equal to - property greater than or equal to the given value.Greater Than - property greater than the given value.Case insensitive Contains.Case insensitive Ends With.Case Insensitive Equal To.In - property has a value contained in the set of values.Is Not Null - property is not null.Is Null - property is null.istartsWith
(String propertyName, String value) Case insensitive Starts With.Less Than or Equal to - property less than or equal to the given value.Less Than - property less than the given value.maxRows
(int maxRows) Specify the maximum number of rows/elements to return.Not Equal To - property not equal to the given value.Specify a sortByClause.startsWith
(String propertyName, String value) Starts With.
-
Method Details
-
sort
Specify a sortByClause.The sort (if specified) will always execute first followed by the filter expressions.
Refer to
DB.sort(List, String)
for more detail. -
maxRows
Specify the maximum number of rows/elements to return. -
eq
Equal To - property equal to the given value. -
ne
Not Equal To - property not equal to the given value. -
ieq
Case Insensitive Equal To. -
between
Between - property between the two given values. -
gt
Greater Than - property greater than the given value. -
ge
Greater Than or Equal to - property greater than or equal to the given value. -
lt
Less Than - property less than the given value. -
le
Less Than or Equal to - property less than or equal to the given value. -
isNull
Is Null - property is null. -
isNotNull
Is Not Null - property is not null. -
startsWith
Starts With. -
istartsWith
Case insensitive Starts With. -
endsWith
Ends With. -
iendsWith
Case insensitive Ends With. -
contains
Contains - property contains the string "value". -
icontains
Case insensitive Contains. -
in
In - property has a value contained in the set of values. -
filter
Apply the filter to the list returning a new list of the matching elements in the sorted order.The sourceList will remain unmodified.
- Returns:
- Returns a new list with the sorting and filters applied.
-