Package net.sf.basedb.core.query
Class Selects
- java.lang.Object
-
- net.sf.basedb.core.query.Selects
-
public class Selects extends Object
A factory class to create select expressions.- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2015-04-21 09:59:42 +0200 (ti, 21 apr 2015) $
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
ALIAS_REGEXP
An alias can only contain the characters a-z, A-Z or 0-9.
-
Constructor Summary
Constructors Constructor Description Selects()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Select
expression(Expression e1, String alias)
Same asexpression(e1, alias, false)
.static Select
expression(Expression e1, String alias, boolean useInDistinctCount)
Create a selection from an expression, optionally giving it an alias.
-
-
-
Field Detail
-
ALIAS_REGEXP
public static final Pattern ALIAS_REGEXP
An alias can only contain the characters a-z, A-Z or 0-9.
-
-
Method Detail
-
expression
public static final Select expression(Expression e1, String alias) throws InvalidDataException
Same asexpression(e1, alias, false)
.- Parameters:
e1
- The expression to select. Null is not allowedalias
- The alias to give the expression. Only characters a-z, A-Z and 0-9 are allowed. Null is allowed.- Returns:
- A selection query element
- Throws:
InvalidDataException
- If the required parameter is null or if illegal characters is used inalias
- See Also:
expression(Expression, String, boolean)
-
expression
public static final Select expression(Expression e1, String alias, boolean useInDistinctCount) throws InvalidDataException
Create a selection from an expression, optionally giving it an alias. The alias can be used when getting the result to find the column index. SeeSqlResultIterator.getIndex(String)
.SELECT <expression> AS <alias> FROM ...
The useInDistinctCount parameter affects the
Query.count(DbControl)
method, if theQuery.setDistinct(boolean)
has been set to true. In this case only expressions which has been created for use with the distinct function are used in the selection list:SELECT COUNT(DISTINCT <expression>) FROM ...
- Parameters:
e1
- The expression to selectalias
- The alias to give the expressionuseInDistinctCount
- If the expression should be used when counting distinct values- Returns:
- A selection query element
- Throws:
InvalidDataException
- If the expression is null or if the alias contains invalid characters
-
-