public class DefaultExpressionList<T> extends Object implements SpiExpressionList<T>
| Modifier and Type | Field and Description |
|---|---|
protected ExpressionFactory |
expr |
protected List<SpiExpression> |
list |
protected ExpressionList<T> |
parentExprList |
protected Query<T> |
query |
| Modifier | Constructor and Description |
|---|---|
|
DefaultExpressionList(Query<T> query,
ExpressionFactory expr,
ExpressionList<T> parentExprList) |
protected |
DefaultExpressionList(Query<T> query,
ExpressionFactory expr,
ExpressionList<T> parentExprList,
List<SpiExpression> list) |
|
DefaultExpressionList(Query<T> query,
ExpressionList<T> parentExprList) |
| Modifier and Type | Method and Description |
|---|---|
ExpressionList<T> |
add(Expression expr)
Add an Expression to the list.
|
ExpressionList<T> |
addAll(ExpressionList<T> exprList)
Add a list of Expressions to this ExpressionList.s
|
ExpressionList<T> |
allEq(Map<String,Object> propertyMap)
All Equal - Map containing property names and their values.
|
ExpressionList<T> |
and(Expression expOne,
Expression expTwo)
And - join two expressions with a logical and.
|
ExpressionList<T> |
between(String propertyName,
Object value1,
Object value2)
Between - property between the two given values.
|
ExpressionList<T> |
betweenProperties(String lowProperty,
String highProperty,
Object value)
Between - value between the two properties.
|
ArrayList<Object> |
buildBindValues(SpiExpressionRequest request)
Combine the expression bind values into a list.
|
String |
buildSql(SpiExpressionRequest request)
Concatenate the expression sql into a String.
|
Junction<T> |
conjunction()
Return a list of expressions that will be joined by AND's.
|
ExpressionList<T> |
contains(String propertyName,
String value)
Contains - property like %value%.
|
void |
containsMany(BeanDescriptor<?> desc,
ManyWhereJoins whereManyJoins)
Return true if one of the expressions is related to a Many property.
|
DefaultExpressionList<T> |
copy(Query<T> query)
Return a copy of the expression list.
|
Junction<T> |
disjunction()
Return a list of expressions that will be joined by OR's.
|
ExpressionList<T> |
endJunction()
End a Conjunction or Disjunction returning the parent expression list.
|
ExpressionList<T> |
endsWith(String propertyName,
String value)
Ends With - property like %value.
|
ExpressionList<T> |
eq(String propertyName,
Object value)
Equal To - property is equal to a given value.
|
ExpressionList<T> |
exampleLike(Object example)
A "Query By Example" type of expression.
|
ExpressionList<T> |
filterMany(String prop) |
FutureIds<T> |
findFutureIds()
Execute find Id's query in a background thread.
|
FutureList<T> |
findFutureList()
Execute find list query in a background thread.
|
FutureRowCount<T> |
findFutureRowCount()
Execute find row count query in a background thread.
|
List<Object> |
findIds()
Execute the query returning the list of Id's.
|
QueryIterator<T> |
findIterate()
Execute the query iterating over the results.
|
List<T> |
findList()
Execute the query returning a list.
|
Map<?,T> |
findMap()
Execute the query returning a map.
|
<K> Map<K,T> |
findMap(String keyProperty,
Class<K> keyType)
Return a typed map specifying the key property and type.
|
PagingList<T> |
findPagingList(int pageSize)
Return a PagingList for this query.
|
int |
findRowCount()
Return the count of entities this query should return.
|
Set<T> |
findSet()
Execute the query returning a set.
|
T |
findUnique()
Execute the query returning a single bean.
|
void |
findVisit(QueryResultVisitor<T> visitor)
Execute the query visiting the results.
|
ExpressionList<T> |
ge(String propertyName,
Object value)
Greater Than or Equal to - property greater than or equal to the given
value.
|
List<SpiExpression> |
getUnderlyingList()
Return the underlying list of expressions.
|
ExpressionList<T> |
gt(String propertyName,
Object value)
Greater Than - property greater than the given value.
|
ExpressionList<T> |
having()
Add expressions to the having clause.
|
ExpressionList<T> |
icontains(String propertyName,
String value)
Case insensitive Contains - property like %value%.
|
ExpressionList<T> |
idEq(Object value)
Id Equal to - ID property is equal to the value.
|
ExpressionList<T> |
idIn(List<?> idList)
Id IN a list of id values.
|
ExpressionList<T> |
iendsWith(String propertyName,
String value)
Case insensitive Ends With - property like %value.
|
ExpressionList<T> |
ieq(String propertyName,
String value)
Case Insensitive Equal To - property equal to the given value (typically
using a lower() function to make it case insensitive).
|
ExpressionList<T> |
iexampleLike(Object example)
Case insensitive version of
ExpressionList.exampleLike(Object) |
ExpressionList<T> |
ilike(String propertyName,
String value)
Case insensitive Like - property like value where the value contains the
SQL wild card characters % (percentage) and _ (underscore).
|
ExpressionList<T> |
in(String propertyName,
Collection<?> values)
In - property has a value in the collection of values.
|
ExpressionList<T> |
in(String propertyName,
Object... values)
In - property has a value in the array of values.
|
ExpressionList<T> |
in(String propertyName,
Query<?> subQuery)
In - using a subQuery.
|
List<SpiExpression> |
internalList() |
boolean |
isEmpty()
Return true if this list is empty.
|
ExpressionList<T> |
isNotNull(String propertyName)
Is Not Null - property is not null.
|
ExpressionList<T> |
isNull(String propertyName)
Is Null - property is null.
|
ExpressionList<T> |
istartsWith(String propertyName,
String value)
Case insensitive Starts With - property like value%.
|
Query<T> |
join(String assocProperties)
Specify a property (associated bean) to join and fetch including
all its properties.
|
Query<T> |
join(String assocProperty,
String assocProperties)
Specify a property (associated bean) to join and fetch with its
specific properties to include (aka partial object).
|
ExpressionList<T> |
le(String propertyName,
Object value)
Less Than or Equal to - property less than or equal to the given value.
|
ExpressionList<T> |
like(String propertyName,
String value)
Like - property like value where the value contains the SQL wild card
characters % (percentage) and _ (underscore).
|
ExpressionList<T> |
lt(String propertyName,
Object value)
Less Than - property less than the given value.
|
ExpressionList<T> |
ne(String propertyName,
Object value)
Not Equal To - property not equal to the given value.
|
ExpressionList<T> |
not(Expression exp)
Negate the expression (prefix it with NOT).
|
ExpressionList<T> |
or(Expression expOne,
Expression expTwo)
Or - join two expressions with a logical or.
|
OrderBy<T> |
order()
Return the OrderBy so that you can append an ascending or descending
property to the order by clause.
|
Query<T> |
order(String orderByClause)
Set the order by clause replacing the existing order by clause if there is
one.
|
OrderBy<T> |
orderBy()
Return the OrderBy so that you can append an ascending or descending
property to the order by clause.
|
Query<T> |
orderBy(String orderBy)
Add an orderBy clause to the query.
|
Query<T> |
query()
Return the query that owns this expression list.
|
void |
queryAutoFetchHash(HashQueryPlanBuilder builder)
Calculate a hash based on the expressions but excluding the actual bind
values.
|
int |
queryBindHash()
Calculate a hash based on the expressions.
|
void |
queryPlanHash(BeanQueryRequest<?> request,
HashQueryPlanBuilder builder)
Calculate a hash based on the expressions but excluding the actual bind
values.
|
ExpressionList<T> |
raw(String raw)
Add raw expression with no parameters.
|
ExpressionList<T> |
raw(String raw,
Object value)
Add raw expression with a single parameter.
|
ExpressionList<T> |
raw(String raw,
Object[] values)
Add raw expression with an array of parameters.
|
Query<T> |
select(String fetchProperties)
Specify specific properties to fetch on the main/root bean (aka partial
object).
|
Query<T> |
setBackgroundFetchAfter(int backgroundFetchAfter)
Set the number of rows after which the fetching should continue in a
background thread.
|
void |
setExpressionFactory(ExpressionFactory expr)
Set the ExpressionFactory.
|
Query<T> |
setFirstRow(int firstRow)
Set the first row to fetch.
|
Query<T> |
setListener(QueryListener<T> queryListener)
Deprecated.
|
Query<T> |
setMapKey(String mapKey)
Set the name of the property which values become the key of a map.
|
Query<T> |
setMaxRows(int maxRows)
Set the maximum number of rows to fetch.
|
Query<T> |
setOrderBy(String orderBy)
Add an orderBy clause to the query.
|
Query<T> |
setUseCache(boolean useCache)
Set to true to use the query for executing this query.
|
ExpressionList<T> |
startsWith(String propertyName,
String value)
Starts With - property like value%.
|
SpiExpressionList<?> |
trimPath(int prefixTrim)
Return a copy of the ExpressionList with the path trimmed for filterMany() expressions.
|
ExpressionList<T> |
where()
Add another expression to the where clause.
|
protected final List<SpiExpression> list
protected final ExpressionList<T> parentExprList
protected transient ExpressionFactory expr
public DefaultExpressionList(Query<T> query, ExpressionList<T> parentExprList)
public DefaultExpressionList(Query<T> query, ExpressionFactory expr, ExpressionList<T> parentExprList)
protected DefaultExpressionList(Query<T> query, ExpressionFactory expr, ExpressionList<T> parentExprList, List<SpiExpression> list)
public SpiExpressionList<?> trimPath(int prefixTrim)
SpiExpressionListtrimPath in interface SpiExpressionList<T>public List<SpiExpression> internalList()
public void setExpressionFactory(ExpressionFactory expr)
After deserialisation so that it can be further modified.
setExpressionFactory in interface SpiExpressionList<T>public DefaultExpressionList<T> copy(Query<T> query)
Each of the expressions are expected to be immutable and safe to reference.
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins whereManyJoins)
containsMany in interface SpiExpressionList<T>public ExpressionList<T> endJunction()
ExpressionListAlternatively you can always use where() to return the top level expression list.
endJunction in interface ExpressionList<T>public Query<T> query()
ExpressionListThis is a convenience method solely to support a fluid API where the methods are chained together. Adding expressions returns this expression list and this method can be used after that to return back the original query so that further things can be added to it.
query in interface ExpressionList<T>public ExpressionList<T> where()
ExpressionListwhere in interface ExpressionList<T>public OrderBy<T> order()
ExpressionListThis will never return a null. If no order by clause exists then an 'empty' OrderBy object is returned.
order in interface ExpressionList<T>public OrderBy<T> orderBy()
ExpressionListThis will never return a null. If no order by clause exists then an 'empty' OrderBy object is returned.
orderBy in interface ExpressionList<T>public Query<T> order(String orderByClause)
ExpressionListThis follows SQL syntax using commas between each property with the optional asc and desc keywords representing ascending and descending order respectively.
This is EXACTLY the same as ExpressionList.orderBy(String).
order in interface ExpressionList<T>public Query<T> orderBy(String orderBy)
ExpressionListorderBy in interface ExpressionList<T>Query.orderBy(String)public Query<T> setOrderBy(String orderBy)
ExpressionListsetOrderBy in interface ExpressionList<T>Query.orderBy(String)public FutureIds<T> findFutureIds()
ExpressionListThis returns a Future object which can be used to cancel, check the execution status (isDone etc) and get the value (with or without a timeout).
findFutureIds in interface ExpressionList<T>public FutureRowCount<T> findFutureRowCount()
ExpressionListThis returns a Future object which can be used to cancel, check the execution status (isDone etc) and get the value (with or without a timeout).
findFutureRowCount in interface ExpressionList<T>public FutureList<T> findFutureList()
ExpressionListThis returns a Future object which can be used to cancel, check the execution status (isDone etc) and get the value (with or without a timeout).
findFutureList in interface ExpressionList<T>public PagingList<T> findPagingList(int pageSize)
ExpressionListThis can be used to break up a query into multiple queries to fetch the data a page at a time.
This typically works by using a query per page and setting
Query.setFirstRow(int) and and Query.setMaxRows(int) on the
query. This usually would translate into SQL that uses limit offset, rownum
or row_number function to limit the result set.
findPagingList in interface ExpressionList<T>pageSize - the number of beans fetched per Pagepublic int findRowCount()
ExpressionListThis is the number of 'top level' or 'root level' entities.
findRowCount in interface ExpressionList<T>public List<Object> findIds()
ExpressionListfindIds in interface ExpressionList<T>Query.findIds()public void findVisit(QueryResultVisitor<T> visitor)
ExpressionListfindVisit in interface ExpressionList<T>Query.findVisit(QueryResultVisitor)public QueryIterator<T> findIterate()
ExpressionListfindIterate in interface ExpressionList<T>Query.findIterate()public List<T> findList()
ExpressionListfindList in interface ExpressionList<T>Query.findList()public Set<T> findSet()
ExpressionListfindSet in interface ExpressionList<T>Query.findSet()public Map<?,T> findMap()
ExpressionListfindMap in interface ExpressionList<T>Query.findMap()public <K> Map<K,T> findMap(String keyProperty, Class<K> keyType)
ExpressionListfindMap in interface ExpressionList<T>public T findUnique()
ExpressionListfindUnique in interface ExpressionList<T>Query.findUnique()public ExpressionList<T> filterMany(String prop)
filterMany in interface ExpressionList<T>public Query<T> select(String fetchProperties)
ExpressionListselect in interface ExpressionList<T>Query.select(String)public Query<T> join(String assocProperties)
ExpressionListjoin in interface ExpressionList<T>Query#join(String)public Query<T> join(String assocProperty, String assocProperties)
ExpressionListjoin in interface ExpressionList<T>Query#join(String,String)public Query<T> setFirstRow(int firstRow)
ExpressionListsetFirstRow in interface ExpressionList<T>Query.setFirstRow(int)public Query<T> setMaxRows(int maxRows)
ExpressionListsetMaxRows in interface ExpressionList<T>Query.setMaxRows(int)public Query<T> setBackgroundFetchAfter(int backgroundFetchAfter)
ExpressionListsetBackgroundFetchAfter in interface ExpressionList<T>Query.setBackgroundFetchAfter(int)public Query<T> setMapKey(String mapKey)
ExpressionListsetMapKey in interface ExpressionList<T>Query.setMapKey(String)@Deprecated public Query<T> setListener(QueryListener<T> queryListener)
ExpressionListExpressionList.findIterate() or ExpressionList.findVisit(QueryResultVisitor).
Set a QueryListener for bean by bean processing.setListener in interface ExpressionList<T>Query.setListener(QueryListener)public Query<T> setUseCache(boolean useCache)
ExpressionListsetUseCache in interface ExpressionList<T>Query.setUseCache(boolean)public ExpressionList<T> having()
ExpressionListThe having clause is only used for queries based on raw sql (via SqlSelect annotation etc).
having in interface ExpressionList<T>public ExpressionList<T> add(Expression expr)
ExpressionListThis returns the list so that add() can be chained.
Query<Customer> query = Ebean.createQuery(Customer.class);
query.where()
.like("name","Rob%")
.eq("status", Customer.ACTIVE);
List<Customer> list = query.findList();
...
add in interface ExpressionList<T>public ExpressionList<T> addAll(ExpressionList<T> exprList)
ExpressionListaddAll in interface ExpressionList<T>public List<SpiExpression> getUnderlyingList()
SpiExpressionListgetUnderlyingList in interface SpiExpressionList<T>public boolean isEmpty()
SpiExpressionListisEmpty in interface SpiExpressionList<T>public String buildSql(SpiExpressionRequest request)
SpiExpressionListThe list of expressions are evaluated in order building a sql statement with bind parameters.
buildSql in interface SpiExpressionList<T>public ArrayList<Object> buildBindValues(SpiExpressionRequest request)
SpiExpressionListExpressions are evaluated in order and all the resulting bind values are returned as a List.
buildBindValues in interface SpiExpressionList<T>public void queryAutoFetchHash(HashQueryPlanBuilder builder)
public void queryPlanHash(BeanQueryRequest<?> request, HashQueryPlanBuilder builder)
queryPlanHash in interface SpiExpressionList<T>public int queryBindHash()
public ExpressionList<T> eq(String propertyName, Object value)
ExpressionListeq in interface ExpressionList<T>public ExpressionList<T> ieq(String propertyName, String value)
ExpressionListieq in interface ExpressionList<T>public ExpressionList<T> ne(String propertyName, Object value)
ExpressionListne in interface ExpressionList<T>public ExpressionList<T> allEq(Map<String,Object> propertyMap)
ExpressionListExpression where all the property names in the map are equal to the corresponding value.
allEq in interface ExpressionList<T>propertyMap - a map keyed by property names.public ExpressionList<T> and(Expression expOne, Expression expTwo)
ExpressionListand in interface ExpressionList<T>public ExpressionList<T> between(String propertyName, Object value1, Object value2)
ExpressionListbetween in interface ExpressionList<T>public ExpressionList<T> betweenProperties(String lowProperty, String highProperty, Object value)
ExpressionListbetweenProperties in interface ExpressionList<T>public Junction<T> conjunction()
ExpressionListconjunction in interface ExpressionList<T>public ExpressionList<T> contains(String propertyName, String value)
ExpressionListcontains in interface ExpressionList<T>public Junction<T> disjunction()
ExpressionListdisjunction in interface ExpressionList<T>public ExpressionList<T> endsWith(String propertyName, String value)
ExpressionListendsWith in interface ExpressionList<T>public ExpressionList<T> ge(String propertyName, Object value)
ExpressionListge in interface ExpressionList<T>public ExpressionList<T> gt(String propertyName, Object value)
ExpressionListgt in interface ExpressionList<T>public ExpressionList<T> icontains(String propertyName, String value)
ExpressionListicontains in interface ExpressionList<T>public ExpressionList<T> idIn(List<?> idList)
ExpressionListidIn in interface ExpressionList<T>public ExpressionList<T> idEq(Object value)
ExpressionListidEq in interface ExpressionList<T>public ExpressionList<T> iendsWith(String propertyName, String value)
ExpressionListiendsWith in interface ExpressionList<T>public ExpressionList<T> ilike(String propertyName, String value)
ExpressionListilike in interface ExpressionList<T>public ExpressionList<T> in(String propertyName, Query<?> subQuery)
ExpressionListin in interface ExpressionList<T>public ExpressionList<T> in(String propertyName, Collection<?> values)
ExpressionListin in interface ExpressionList<T>public ExpressionList<T> in(String propertyName, Object... values)
ExpressionListin in interface ExpressionList<T>public ExpressionList<T> isNotNull(String propertyName)
ExpressionListisNotNull in interface ExpressionList<T>public ExpressionList<T> isNull(String propertyName)
ExpressionListisNull in interface ExpressionList<T>public ExpressionList<T> istartsWith(String propertyName, String value)
ExpressionLististartsWith in interface ExpressionList<T>public ExpressionList<T> le(String propertyName, Object value)
ExpressionListle in interface ExpressionList<T>public ExpressionList<T> exampleLike(Object example)
ExpressionListPass in an example entity and for each non-null scalar properties an expression is added.
By Default this case sensitive, will ignore numeric zero values and will use a Like for string values (you must put in your own wildcards).
To get control over the options you can create an ExampleExpression and set those options such as case insensitive etc.
// create an example bean and set the properties
// with the query parameters you want
Customer example = new Customer();
example.setName("Rob%");
example.setNotes("%something%");
List<Customer> list = Ebean.find(Customer.class).where()
// pass the bean into the where() clause
.exampleLike(example)
// you can add other expressions to the same query
.gt("id", 2).findList();
Similarly you can create an ExampleExpression
Customer example = new Customer();
example.setName("Rob%");
example.setNotes("%something%");
// create a ExampleExpression with more control
ExampleExpression qbe = new ExampleExpression(example, true, LikeType.EQUAL_TO).includeZeros();
List<Customer> list = Ebean.find(Customer.class).where().add(qbe).findList();
exampleLike in interface ExpressionList<T>public ExpressionList<T> iexampleLike(Object example)
ExpressionListExpressionList.exampleLike(Object)iexampleLike in interface ExpressionList<T>public ExpressionList<T> like(String propertyName, String value)
ExpressionListlike in interface ExpressionList<T>public ExpressionList<T> lt(String propertyName, Object value)
ExpressionListlt in interface ExpressionList<T>public ExpressionList<T> not(Expression exp)
ExpressionListnot in interface ExpressionList<T>public ExpressionList<T> or(Expression expOne, Expression expTwo)
ExpressionListor in interface ExpressionList<T>public ExpressionList<T> raw(String raw, Object value)
ExpressionListThe raw expression should contain a single ? at the location of the parameter.
When properties in the clause are fully qualified as table-column names then they are not translated. logical property name names (not fully qualified) will still be translated to their physical name.
raw in interface ExpressionList<T>public ExpressionList<T> raw(String raw, Object[] values)
ExpressionListThe raw expression should contain the same number of ? as there are parameters.
When properties in the clause are fully qualified as table-column names then they are not translated. logical property name names (not fully qualified) will still be translated to their physical name.
raw in interface ExpressionList<T>public ExpressionList<T> raw(String raw)
ExpressionListWhen properties in the clause are fully qualified as table-column names then they are not translated. logical property name names (not fully qualified) will still be translated to their physical name.
raw in interface ExpressionList<T>public ExpressionList<T> startsWith(String propertyName, String value)
ExpressionListstartsWith in interface ExpressionList<T>Copyright © 2014. All Rights Reserved.