com.avaje.ebean
Interface ExpressionList<T>

All Superinterfaces:
Serializable

public interface ExpressionList<T>
extends Serializable

List of Expressions that make up a where or having clause.

An ExpressionList is returned from Query.where().

The ExpressionList has a list of convenience methods that create the standard expressions and add them to this list.

The ExpressionList also duplicates methods that are found on the Query such as findList() and orderBy(). The purpose of these methods is provide a fluid API. The upside of this approach is that you can build and execute a query via chained methods. The down side is that this ExpressionList object has more methods than you would initially expect (the ones duplicated from Query).

See Also:
Query.where()

Method Summary
 ExpressionList<T> add(Expression expr)
          Add an Expression to the list.
 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.
 Junction conjunction()
          Return a list of expressions that will be joined by AND's.
 ExpressionList<T> contains(String propertyName, String value)
          Contains - property like %value%.
 Junction disjunction()
          Return a list of expressions that will be joined by OR's.
 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<T> findList()
          Execute the query returning a list.
 Map<?,T> findMap()
          Execute the query returning a map.
 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.
 ExpressionList<T> ge(String propertyName, Object value)
          Greater Than or Equal to - property greater than or equal to the given value.
 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<?> idValues)
          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 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.
 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.
 Query<T> orderBy(String orderBy)
          Add an orderBy clause to the query.
 Query<T> query()
          Return the query that owns this expression list.
 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 properties)
          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.
 Query<T> setFirstRow(int firstRow)
          Set the first row to fetch.
 Query<T> setListener(QueryListener<T> queryListener)
          Set a QueryListener for bean by bean processing.
 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%.
 ExpressionList<T> where()
          Add another expression to the where clause.
 

Method Detail

query

Query<T> query()
Return the query that owns this expression list.

This 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.


order

Query<T> order(String orderByClause)
Set the order by clause replacing the existing order by clause if there is one.

This 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 orderBy(String).


order

OrderBy<T> order()
Return the OrderBy so that you can append an ascending or descending property to the order by clause.

This will never return a null. If no order by clause exists then an 'empty' OrderBy object is returned.


orderBy

Query<T> orderBy(String orderBy)
Add an orderBy clause to the query.

See Also:
Query.orderBy(String)

setOrderBy

Query<T> setOrderBy(String orderBy)
Add an orderBy clause to the query.

See Also:
Query.orderBy(String)

findList

List<T> findList()
Execute the query returning a list.

See Also:
Query.findList()

findRowCount

int findRowCount()
Return the count of entities this query should return.

This is the number of 'top level' or 'root level' entities.


findSet

Set<T> findSet()
Execute the query returning a set.

See Also:
Query.findSet()

findMap

Map<?,T> findMap()
Execute the query returning a map.

See Also:
Query.findMap()

findUnique

T findUnique()
Execute the query returning a single bean.

See Also:
Query.findUnique()

findFutureRowCount

FutureRowCount<T> findFutureRowCount()
Execute find row count query in a background thread.

This 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).

Returns:
a Future object for the row count query

findFutureIds

FutureIds<T> findFutureIds()
Execute find Id's query in a background thread.

This 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).

Returns:
a Future object for the list of Id's

findFutureList

FutureList<T> findFutureList()
Execute find list query in a background thread.

This 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).

Returns:
a Future object for the list result of the query

findPagingList

PagingList<T> findPagingList(int pageSize)
Return a PagingList for this query.

This 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.

Parameters:
pageSize - the number of beans fetched per Page

filterMany

ExpressionList<T> filterMany(String prop)

select

Query<T> select(String properties)
Specify specific properties to fetch on the main/root bean (aka partial object).

See Also:
Query.select(String)

join

Query<T> join(String assocProperties)
Specify a property (associated bean) to join and fetch including all its properties.

See Also:
Query.join(String)

join

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).

See Also:
Query.join(String,String)

setFirstRow

Query<T> setFirstRow(int firstRow)
Set the first row to fetch.

See Also:
Query.setFirstRow(int)

setMaxRows

Query<T> setMaxRows(int maxRows)
Set the maximum number of rows to fetch.

See Also:
Query.setMaxRows(int)

setBackgroundFetchAfter

Query<T> setBackgroundFetchAfter(int backgroundFetchAfter)
Set the number of rows after which the fetching should continue in a background thread.

See Also:
Query.setBackgroundFetchAfter(int)

setMapKey

Query<T> setMapKey(String mapKey)
Set the name of the property which values become the key of a map.

See Also:
Query.setMapKey(String)

setListener

Query<T> setListener(QueryListener<T> queryListener)
Set a QueryListener for bean by bean processing.

See Also:
Query.setListener(QueryListener)

setUseCache

Query<T> setUseCache(boolean useCache)
Set to true to use the query for executing this query.

See Also:
Query.setUseCache(boolean)

having

ExpressionList<T> having()
Add expressions to the having clause.

The having clause is only used for queries based on raw sql (via SqlSelect annotation etc).


where

ExpressionList<T> where()
Add another expression to the where clause.


add

ExpressionList<T> add(Expression expr)
Add an Expression to the list.

This 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();
 ...
 


eq

ExpressionList<T> eq(String propertyName,
                     Object value)
Equal To - property is equal to a given value.


ne

ExpressionList<T> ne(String propertyName,
                     Object value)
Not Equal To - property not equal to the given value.


ieq

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).


between

ExpressionList<T> between(String propertyName,
                          Object value1,
                          Object value2)
Between - property between the two given values.


betweenProperties

ExpressionList<T> betweenProperties(String lowProperty,
                                    String highProperty,
                                    Object value)
Between - value between the two properties.


gt

ExpressionList<T> gt(String propertyName,
                     Object value)
Greater Than - property greater than the given value.


ge

ExpressionList<T> ge(String propertyName,
                     Object value)
Greater Than or Equal to - property greater than or equal to the given value.


lt

ExpressionList<T> lt(String propertyName,
                     Object value)
Less Than - property less than the given value.


le

ExpressionList<T> le(String propertyName,
                     Object value)
Less Than or Equal to - property less than or equal to the given value.


isNull

ExpressionList<T> isNull(String propertyName)
Is Null - property is null.


isNotNull

ExpressionList<T> isNotNull(String propertyName)
Is Not Null - property is not null.


exampleLike

ExpressionList<T> exampleLike(Object example)
A "Query By Example" type of expression.

Pass 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();
 


iexampleLike

ExpressionList<T> iexampleLike(Object example)
Case insensitive version of exampleLike(Object)


like

ExpressionList<T> like(String propertyName,
                       String value)
Like - property like value where the value contains the SQL wild card characters % (percentage) and _ (underscore).


ilike

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). Typically uses a lower() function to make the expression case insensitive.


startsWith

ExpressionList<T> startsWith(String propertyName,
                             String value)
Starts With - property like value%.


istartsWith

ExpressionList<T> istartsWith(String propertyName,
                              String value)
Case insensitive Starts With - property like value%. Typically uses a lower() function to make the expression case insensitive.


endsWith

ExpressionList<T> endsWith(String propertyName,
                           String value)
Ends With - property like %value.


iendsWith

ExpressionList<T> iendsWith(String propertyName,
                            String value)
Case insensitive Ends With - property like %value. Typically uses a lower() function to make the expression case insensitive.


contains

ExpressionList<T> contains(String propertyName,
                           String value)
Contains - property like %value%.


icontains

ExpressionList<T> icontains(String propertyName,
                            String value)
Case insensitive Contains - property like %value%. Typically uses a lower() function to make the expression case insensitive.


in

ExpressionList<T> in(String propertyName,
                     Query<?> subQuery)
In - using a subQuery.


in

ExpressionList<T> in(String propertyName,
                     Object[] values)
In - property has a value in the array of values.


in

ExpressionList<T> in(String propertyName,
                     Collection<?> values)
In - property has a value in the collection of values.


idIn

ExpressionList<T> idIn(List<?> idValues)
Id IN a list of id values.


idEq

ExpressionList<T> idEq(Object value)
Id Equal to - ID property is equal to the value.


allEq

ExpressionList<T> allEq(Map<String,Object> propertyMap)
All Equal - Map containing property names and their values.

Expression where all the property names in the map are equal to the corresponding value.

Parameters:
propertyMap - a map keyed by property names.

raw

ExpressionList<T> raw(String raw,
                      Object value)
Add raw expression with a single parameter.

The 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

ExpressionList<T> raw(String raw,
                      Object[] values)
Add raw expression with an array of parameters.

The 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

ExpressionList<T> raw(String raw)
Add raw expression with no 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.


and

ExpressionList<T> and(Expression expOne,
                      Expression expTwo)
And - join two expressions with a logical and.


or

ExpressionList<T> or(Expression expOne,
                     Expression expTwo)
Or - join two expressions with a logical or.


not

ExpressionList<T> not(Expression exp)
Negate the expression (prefix it with NOT).


conjunction

Junction conjunction()
Return a list of expressions that will be joined by AND's.


disjunction

Junction disjunction()
Return a list of expressions that will be joined by OR's.



Copyright © 2010. All Rights Reserved.