Package org.apache.empire.db
Class DBColumnExpr
java.lang.Object
org.apache.empire.db.DBObject
org.apache.empire.db.DBExpr
org.apache.empire.db.DBColumnExpr
- All Implemented Interfaces:
ColumnExpr
- Direct Known Subclasses:
DBAbstractFuncExpr,DBAliasExpr,DBCalcExpr,DBCaseExpr,DBCmdResultExpr,DBColumn,DBConcatExpr,DBCountExpr,DBParenthesisExpr,DBScalarExpr,DBValueExpr,DBVarArgsFuncExpr,OracleRowNumExpr,PostgresBoolAndOrExpr,PostgresIntervalExpr
This class is the base class for all expressions that represent a single value.
It provides a set of factory functions for SQL functions.
-
Field Summary
FieldsFields inherited from class org.apache.empire.db.DBExpr
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESIS, CTX_VALUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal DBFuncExprabs()Creates and returns a sql-expression for the absolute abs() function.abstract ElementAdd a description of this column with relevant metadata to the supplied parent XML Element.final DBColumnExprCreates and returns a function from an sql template The template may consist of the following placeholders: ?Creates a new DBConcatExpr object with the specified value.creates a new DBAliasExpr which renames the current expression to the supplied name.final DBAliasExprcreates a new DBAliasExpr which renames the current expression to the name of the supplied column.asc()creates a new DBOrderByExpr for ascending orderfinal DBFuncExpravg()Creates and returns an aggregation function object which returns the average value for the current expression over a group of rows.final DBFuncExprceiling()Create and returns an expression for the SQL-function ceil()Creates and returns a new comparison object for the given comparison operator and value.Creates a sql-expression for the nvl() or coalesce() function.concat(String separator, DBColumnExpr... concatExprs) concatenates a list of expressions to the current columnconcat(DBColumnExpr... concatExprs) concatenates a list of expressions to the current columnfinal DBCompareColExprCreates and returns a new comparison object for the "contains(column, val)" comparatorfinal DBConvertExprCreates and returns a new DBFuncExpr object that will convert the current column to the destination data type specified.Creates a new DBFuncExpr object that will convert the current column to the destination data type specified.count()Creates and returns an expression for the SQL "count()" function which returns the number of rows in the result set.Creates and returns an expression for the SQL "count()" function which returns the number of unique values in the result set.final DBFuncExprday()Creates and returns an function object that calculates the day of a date value.final DBDecodeExprfinal DBDecodeExprfinal DBDecodeExprdecode(Object key1, Object value1, Object key2, Object value2, Object key3, Object value3, Object otherwise) Creates and returns a sql-expression that compares the current column expression with a list of values and returns the corresponding alternative value.final DBDecodeExprfinal DBDecodeExprdecodeEnum(Class<? extends Enum<?>> enumType, String otherwise) Creates and returns a sql-expression that maps enum values by name or ordinal to their string representationdecodeSort(Class<? extends Enum<?>> enumType, boolean defaultToEnd) Creates and returns a sql-expression that maps enum values from name to ordinal This is useful for sorting.desc()creates a new DBOrderByExpr for descending orderCreates and returns a new calculation object for the SQL "/" (divide) operator.final DBFuncExprfloor()Create and returns an expression for the SQL-function floor()final DBFuncExprFormats a column-expression using a format string This function is intended for formatting numbers.final DBColumnExprCreates and returns a function from an sql template The template may consist of the following placeholders: ?getAttribute(String name) Returns the value of a column attribute.<T> TgetAttribute(String name, Class<T> type) Returns the value of a column attribute and converts it to the desired typeGets the Java bean property name for this column i.e.final StringReturns the column control type.abstract DataTypeReturns the data type of this column expression.booleanReturns the default sort order FALSE is for ascending, TRUE for descendingprotected final DBFuncExprgetExprFromPhrase(DBSqlPhrase phrase, Object[] params) protected DBFuncExprgetExprFromPhrase(DBSqlPhrase phrase, Object[] params, DataType dataType) Creates a new DBFuncExpr from a given SQL-PRHASE and optional additional parameters.Returns an expression which ignores the case Only for case sensitive columns!Class<?>returns a corresponding Java type for this expressionabstract StringgetName()Returns the column name for this column expression.getNumberType(ColumnExpr columnExpr) Returns the number type assigned to this column expressionReturns the list of options for this column containing all possible field values.abstract DBRowSetReturns the underlying rowset containing this column For functions involving none or more than one physical column this function return the first onefinal DBColumnDeprecated.final StringgetTitle()Returns the title attribute.abstract DBColumnReturns the underlying physical column.final DBCompareColExprin(Collection<?> values) Creates and returns an expression for the SQL "in" operator.final DBCompareColExprCreates and returns an expression for the SQL "not in" operator.final <T> DBCompareColExprin(T... values) Creates and returns an expression for the SQL "in" operator.final DBFuncExprCreates and returns a sql-expression that returns the position of a string in the current column expression.final DBFuncExprOverloaded.final DBFuncExprCreates and returns a sql-expression that returns the position of a string in the current column expression.final DBCompareColExprCreates and returns a new comparison object for the SQL "=" (equal) operator.abstract booleanIndicates whether this function is an aggregate (sum, min, max, avg, ...) or notfinal DBCompareColExprCreates and returns a new comparison object for the SQL "between" operator.booleanReturns whether or not a columnExpr is case sensitive If not explicitly set, the case sensitivity is true for all text fields (VARCHAR, CLOB) except if an EnumType is set.final DBCompareColExprisGreaterThan(Object value) Creates and returns a new comparison object for the SQL ">" (greater than) operator.final DBCompareColExprisLessOrEqual(Object value) Creates and returns a new comparison object for the SQL "<=" (less or equal) operator.protected booleanisLiteralValue(Object value) Checks if a value is a literal valuefinal DBCompareColExprisMoreOrEqual(Object value) Creates and returns a new comparison object for the SQL ">=" (greater or equal) operator.final DBCompareColExprCreates and returns a new comparison object for the SQL "<>" (not equal) operator.final DBCompareColExprisNotBetween(Object minValue, Object maxValue) Creates and returns a new comparison object for the SQL "not between" operator.final DBCompareColExprisSmallerThan(Object value) Creates and returns a new comparison object for the SQL "<" (less than) operator.final DBFuncExprlength()Creates and returns a sql-expression that returns the string length of this expression.final DBCompareColExprCreates and returns a new comparison object for the SQL "like" operator.Creates and returns a new comparison object for the SQL "like" operator.Deprecated.Always user likeUpper() for case insensitive comparisonsCreates and returns a new case insensitive comparison for the SQL "like" operator.final DBFuncExprlower()Creates and returns a function object which converts the current expression to lower case.final DBFuncExprmax()Creates and returns an aggregation function object which returns the maximum value for the current expression over a group of rows.final DBFuncExprmin()Creates and returns an aggregation function object which returns the minimum value for the current expression over a group of rows.minus(int value) Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is negative or positive.Creates and returns a new calculation object for the SQL "-" (minus) operator.final DBFuncExprCreates a sql-expression for the modulo or mod() function.final DBFuncExprmonth()Creates and returns an function object that calculates the month of a date value.multiplyWith(Object value) Creates and returns a new calculation object for the SQL "*" (multiply) operator.final DBCompareColExprnotContains(Object value) Creates and returns a new comparison object for the "not contains(column, val)" comparatorfinal DBCompareColExprnotIn(Collection<?> values) Creates and returns an expression for the SQL "not in" operator.final DBCompareColExprCreates and returns an expression for the SQL "not in" operator.final <T> DBCompareColExprnotIn(T... values) Creates and returns an expression for the SQL "not in" operator.final DBCompareColExprCreates and returns a new comparison object for the SQL "not like" operator.Deprecated.Outdated oracle syntax - use coalesce insteadon(DBColumnExpr joinWith) create a join expression for DBCommand.join()Creates and returns a function object which encloses the current expression in parenthesis.plus(int value) Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is positive or negative.Creates and returns a new calculation object for the SQL "+" (plus) operator.Puts a value or expression before the current expressionreturns an expression that renames the column with its alias namefinal DBFuncExprCreates and returns a sql-expression for the replace(...) function.final DBFuncExprreverse()Creates and returns a sql-expression for the reverse(...) function.final DBFuncExprround(int decimals) Creates and returns an function object that rounds a number espression with the given decimals.<T extends ColumnExpr>
TsetAttribute(String name, Object value) Sets the value of a column attribute.<T extends DBColumnExpr>
TsetBeanPropertyName(String propertyName) Sets the Java bean property name for this column.final <T extends DBColumnExpr>
TsetControlType(String controlType) Sets the controlType attribute.<T extends DBColumnExpr>
TsetDefaultSortOrder(Boolean descending) Sets the default sort order<T extends DBColumnExpr>
TsetOptions(Options options) Sets the options for this column indicating all valid values.<T extends DBColumnExpr>
TSets the title attribute.final DBFuncExprCreates and returns string aggregation expressionfinal DBFuncExprstringAgg(String separator, DBOrderByExpr orderBy) Creates and returns string aggregation expressionsubstring(int pos) Overloaded.substring(int pos, int count) Overloaded.Overloaded.final DBFuncExprCreates and returns a sql-expression for the substring(...) function.Overloaded.final DBFuncExprCreates and returns a sql-expression for the substring(...) function.final DBFuncExprsum()Creates and returns an aggregation function object which calculates the sum for the current expression over a group of rows.final DBConvertExprtoChar()Creates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ")"final DBConvertExprCreates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ", * '"+format+"')"toString()For Debuggingfinal DBFuncExprtrim()Creates and returns a sql-expression for the trim() function.final DBFuncExprtrimLeft()Creates and returns a sql-expression for the ltrim() function.final DBFuncExprCreates and returns a sql-expression for the rtrim() function.final DBFuncExprtrunc(int decimals) Creates and returns an function object that truncates a number espression with the given decimals.final DBFuncExprupper()Creates and returns a function object which converts the current expression to upper case.final DBCaseExprwhen(DBCompareExpr compExpr, Object otherwise) Creates and returns a sql-expression for the SQL case-phrase.
The result will be in the form:
"case when [compExpr] then [this] else [otherwise] end"final DBFuncExpryear()Creates and returns an function object that calculates the year of a date value.Methods inherited from class org.apache.empire.db.DBExpr
addReferencedColumns, addSQLMethods inherited from class org.apache.empire.db.DBObject
checkParamNull, getDatabaseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.empire.data.ColumnExpr
getEnumType
-
Field Details
-
attributes
-
options
-
beanPropertyName
-
-
Constructor Details
-
DBColumnExpr
public DBColumnExpr()
-
-
Method Details
-
getDataType
Returns the data type of this column expression.- Specified by:
getDataTypein interfaceColumnExpr- Returns:
- the expressions data type
- See Also:
-
getName
Returns the column name for this column expression. The name must contain only alphanumeric characters and the underscore. For SQL functions this name may be generated. However subsequent calls to this function for the same object instance must return the same string.- Specified by:
getNamein interfaceColumnExpr- Returns:
- the column name
-
getRowSet
Returns the underlying rowset containing this column For functions involving none or more than one physical column this function return the first one- Returns:
- a column used for this expression
-
getUpdateColumn
Returns the underlying physical column. For functions involving none or more than one physical column this function returns null.- Specified by:
getUpdateColumnin interfaceColumnExpr- Returns:
- the underlying column
-
getSourceColumn
Deprecated.Use getUpdateColumn() instead!- Specified by:
getSourceColumnin interfaceColumnExpr
-
isAggregate
public abstract boolean isAggregate()Indicates whether this function is an aggregate (sum, min, max, avg, ...) or not- Returns:
- true if the column expression represents an aggregate
-
addXml
Add a description of this column with relevant metadata to the supplied parent XML Element.- Parameters:
parent- the parent element to which to append the column descriptionflags- currently not used- Returns:
- the newly created child element
-
qualified
returns an expression that renames the column with its alias name- Returns:
- the rename expression
-
getAttribute
Returns the value of a column attribute. Column attributes are used to provide metadata for a column.- Specified by:
getAttributein interfaceColumnExpr- Parameters:
name- the attribute name- Returns:
- value of the attribute if it exists or null otherwise
-
getAttribute
Returns the value of a column attribute and converts it to the desired type- Parameters:
name- the attribute nametype- the desired Java type- Returns:
- value of the attribute
-
setAttribute
Sets the value of a column attribute. Same as Column.setAttribute but with different name to avoid name clash- Specified by:
setAttributein interfaceColumnExpr- Type Parameters:
T- the column expression type- Parameters:
name- the attribute namevalue- the value of the attribute- Returns:
- returns self (this)
-
getOptions
Returns the list of options for this column containing all possible field values.- Specified by:
getOptionsin interfaceColumnExpr- Returns:
- the list of options
-
setOptions
Sets the options for this column indicating all valid values.- Type Parameters:
T- the column expression type- Parameters:
options- the list of options- Returns:
- returns self (this)
-
getTitle
Returns the title attribute.- Specified by:
getTitlein interfaceColumnExpr- Returns:
- the column title
-
setTitle
Sets the title attribute.- Type Parameters:
T- the column expression type- Parameters:
title- the column title- Returns:
- returns self (this)
-
getControlType
Returns the column control type. The control type is a client specific name for the type of input control that should be used to display and edit values for this column.- Specified by:
getControlTypein interfaceColumnExpr- Returns:
- the column control type
-
setControlType
Sets the controlType attribute.- Type Parameters:
T- the column expression type- Parameters:
controlType- the column control type- Returns:
- returns self (this)
-
getBeanPropertyName
Gets the Java bean property name for this column i.e. ID = employeeId DATE_OF_BIRTH = dateOfBirth- Specified by:
getBeanPropertyNamein interfaceColumnExpr- Returns:
- the name of the bean property used to get and set values
-
setBeanPropertyName
Sets the Java bean property name for this column.- Type Parameters:
T- the column expression type- Parameters:
propertyName- the property name- Returns:
- returns self (this)
-
getDefaultSortOrder
public boolean getDefaultSortOrder()Returns the default sort order FALSE is for ascending, TRUE for descending- Returns:
- true if the default sort order is descending
-
setDefaultSortOrder
Sets the default sort order- Parameters:
descending- true if the default sort order is ascending or false if descending- Returns:
- returns self (this)
-
isCaseSensitive
public boolean isCaseSensitive()Returns whether or not a columnExpr is case sensitive If not explicitly set, the case sensitivity is true for all text fields (VARCHAR, CLOB) except if an EnumType is set.- Returns:
- true if the columnExpr is case sensitive or false if not
-
getIgnoreCaseExpr
Returns an expression which ignores the case Only for case sensitive columns! Default is upper(expr)- Returns:
- the ignore case expression or the expression itself
-
getNumberType
Returns the number type assigned to this column expression- Parameters:
columnExpr- the columnExpr- Returns:
- the number type
-
as
creates a new DBAliasExpr which renames the current expression to the supplied name.- Parameters:
alias- the alias name- Returns:
- the new DBAliasExpr object
-
as
creates a new DBAliasExpr which renames the current expression to the name of the supplied column.- Parameters:
column- the column whose name serves as an alias for the current expression- Returns:
- the new DBAliasExpr object
-
cmp
Creates and returns a new comparison object for the given comparison operator and value.- Parameters:
op- the comparison operatorvalue- the Object value- Returns:
- the new DBCompareColExpr object
-
like
Creates and returns a new comparison object for the SQL "like" operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
likeUpper
Creates and returns a new case insensitive comparison for the SQL "like" operator. Case insensitivity is achieved by calling getIgnoreCaseExpr() Hence the case insensitive operation is determined by the DBMSHandler Default is upper(value)- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
likeLower
Deprecated.Always user likeUpper() for case insensitive comparisonsCreates and returns a new comparison object for the SQL "like" operator. Converts the column value and comparison value to lower case- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
like
Creates and returns a new comparison object for the SQL "like" operator.- Parameters:
value- the Object valueescape- the escape character- Returns:
- the new DBCompareColExpr object
-
notLike
Creates and returns a new comparison object for the SQL "not like" operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
contains
Creates and returns a new comparison object for the "contains(column, val)" comparator- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
notContains
Creates and returns a new comparison object for the "not contains(column, val)" comparator- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
is
Creates and returns a new comparison object for the SQL "=" (equal) operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
isNot
Creates and returns a new comparison object for the SQL "<>" (not equal) operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
in
Creates and returns an expression for the SQL "in" operator.- Parameters:
values- the values to compare this column with- Returns:
- a DBCompareColExpr for the "in" operator
-
in
Creates and returns an expression for the SQL "in" operator.- Type Parameters:
T- the value type- Parameters:
values- the values to compare this column with- Returns:
- a DBCompareColExpr for the "in" operator
-
in
Creates and returns an expression for the SQL "not in" operator.- Parameters:
expr- a database expression to provide a list of values- Returns:
- a DBCompareColExpr for the "not in" operator
-
notIn
Creates and returns an expression for the SQL "not in" operator.- Parameters:
values- the values to compare this column with- Returns:
- a DBCompareColExpr for the "not in" operator
-
notIn
Creates and returns an expression for the SQL "not in" operator.- Type Parameters:
T- the value type- Parameters:
values- the values to compare this column with- Returns:
- a DBCompareColExpr for the "not in" operator
-
notIn
Creates and returns an expression for the SQL "not in" operator.- Parameters:
expr- a database expression to provide a list of values- Returns:
- a DBCompareColExpr for the "not in" operator
-
isBetween
Creates and returns a new comparison object for the SQL "between" operator.- Parameters:
minValue- the minimum valuemaxValue- the maximum value- Returns:
- the new DBCompareColExpr object
-
isNotBetween
Creates and returns a new comparison object for the SQL "not between" operator.- Parameters:
minValue- the minimum valuemaxValue- the maximum value- Returns:
- the new DBCompareColExpr object
-
isGreaterThan
Creates and returns a new comparison object for the SQL ">" (greater than) operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
isMoreOrEqual
Creates and returns a new comparison object for the SQL ">=" (greater or equal) operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
isLessOrEqual
Creates and returns a new comparison object for the SQL "<=" (less or equal) operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
isSmallerThan
Creates and returns a new comparison object for the SQL "<" (less than) operator.- Parameters:
value- the Object value- Returns:
- the new DBCompareColExpr object
-
multiplyWith
Creates and returns a new calculation object for the SQL "*" (multiply) operator.- Parameters:
value- the multiply value- Returns:
- the new DBCalcExpr object
-
divideBy
Creates and returns a new calculation object for the SQL "/" (divide) operator.- Parameters:
value- the divide value- Returns:
- the new DBCalcExpr object
-
plus
Creates and returns a new calculation object for the SQL "+" (plus) operator.- Parameters:
value- the summate value- Returns:
- the new DBCalcExpr object
-
minus
Creates and returns a new calculation object for the SQL "-" (minus) operator.- Parameters:
value- the subtract value- Returns:
- the new DBCalcExpr object
-
plus
Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is positive or negative.- Parameters:
value- the subtract value- Returns:
- the new DBCalcExpr object
-
minus
Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is negative or positive.- Parameters:
value- the subtract value- Returns:
- the new DBCalcExpr object
-
append
Creates a new DBConcatExpr object with the specified value.- Parameters:
value- an Object value- Returns:
- the new DBConcatExpr object
-
getExprFromPhrase
Creates a new DBFuncExpr from a given SQL-PRHASE and optional additional parameters.- Parameters:
phrase- the id of the SQL-phraseparams- the params to replace in the templatedataType- the resulting data Type- Returns:
- the new DBCalcExpr object
-
getExprFromPhrase
-
parenthesis
Creates and returns a function object which encloses the current expression in parenthesis.- Returns:
- the new DBFuncExpr object
-
coalesce
Creates a sql-expression for the nvl() or coalesce() function.- Parameters:
nullValue- the alternative value when this expression is null- Returns:
- the coalesce expression
-
modulo
Creates a sql-expression for the modulo or mod() function.- Parameters:
divisor- the Object value- Returns:
- the new DBFuncExpr object
-
nvl
Deprecated.Outdated oracle syntax - use coalesce insteadCreates a sql-expression for the nvl() or coalesce() function.- Parameters:
nullValue- the int value- Returns:
- the new DBFuncExpr object
-
substring
Creates and returns a sql-expression for the substring(...) function.- Parameters:
pos- the position number of the string- Returns:
- the new DBFuncExpr object
-
substring
Overloaded. @see substring(DBExpr pos)- Parameters:
pos- the position number of the string- Returns:
- the new DBFuncExpr object
-
substring
Creates and returns a sql-expression for the substring(...) function.- Parameters:
pos- the position number of the stringcount- the length of the substring- Returns:
- the new DBFuncExpr object
-
substring
Overloaded. @see substring(DBExpr pos, DBExpr count)- Parameters:
pos- the position number of the stringcount- the length of the substring- Returns:
- the new DBFuncExpr object
-
substring
Overloaded. @see substring(DBExpr pos, DBExpr count)- Parameters:
pos- the position number of the stringcount- the length of the substring- Returns:
- the new DBFuncExpr object
-
substring
Overloaded. @see substring(DBExpr pos, DBExpr count)- Parameters:
pos- the position number of the stringcount- the length of the substring- Returns:
- the new DBFuncExpr object
-
replace
Creates and returns a sql-expression for the replace(...) function.- Parameters:
match- string to replacereplace- string with replacement- Returns:
- the new DBFuncExpr object
-
reverse
Creates and returns a sql-expression for the reverse(...) function.- Returns:
- the new DBFuncExpr object
-
trim
Creates and returns a sql-expression for the trim() function.- Returns:
- the new DBFuncExpr object
-
trimLeft
Creates and returns a sql-expression for the ltrim() function.- Returns:
- the new DBFuncExpr object
-
trimRight
Creates and returns a sql-expression for the rtrim() function.- Returns:
- the new DBFuncExpr object
-
upper
Creates and returns a function object which converts the current expression to upper case.- Returns:
- the new DBFuncExpr object
-
lower
Creates and returns a function object which converts the current expression to lower case.- Returns:
- the new DBFuncExpr object
-
format
Formats a column-expression using a format string This function is intended for formatting numbers. Formatting any other data types may not supported and be database specific- Parameters:
format- the format string. Beware: This is passed to the database "as is" and hence may be database specific.- Returns:
- a string expression representing the formatted value
-
length
Creates and returns a sql-expression that returns the string length of this expression.- Returns:
- the new DBFuncExpr object
-
indexOf
Creates and returns a sql-expression that returns the position of a string in the current column expression.- Parameters:
str- the string to find the position of- Returns:
- the new DBFuncExpr object
-
indexOf
Creates and returns a sql-expression that returns the position of a string in the current column expression.- Parameters:
str- the string to find the position offromPos- the start position for the search- Returns:
- the new DBFuncExpr object
-
indexOf
Overloaded. @see indexOf(Object str, DBExpr fromPos)- Parameters:
str- the string to find the position offromPos- the start position for the search- Returns:
- the new DBFuncExpr object
-
concat
concatenates a list of expressions to the current column- Parameters:
concatExprs- the expressions to concat- Returns:
- the concat expression
-
concat
concatenates a list of expressions to the current column- Parameters:
separator- a string to insert between each of the expressionsconcatExprs- the expressions to concat- Returns:
- the concat expression
-
prepend
Puts a value or expression before the current expression- Parameters:
value- the expressions to prepend- Returns:
- the combined value
-
abs
Creates and returns a sql-expression for the absolute abs() function.- Returns:
- the new DBFuncExpr object
-
floor
Create and returns an expression for the SQL-function floor()- Returns:
- the new DBFuncExpr object
-
ceiling
Create and returns an expression for the SQL-function ceil()- Returns:
- the new DBFuncExpr object
-
round
Creates and returns an function object that rounds a number espression with the given decimals.- Parameters:
decimals- the number of decimal to which to truncate the current value- Returns:
- the new DBFuncExpr object
-
trunc
Creates and returns an function object that truncates a number espression with the given decimals.- Parameters:
decimals- the number of decimal to which to truncate the current value- Returns:
- the new DBFuncExpr object
-
year
Creates and returns an function object that calculates the year of a date value.- Returns:
- the new DBColumnExpr object
-
month
Creates and returns an function object that calculates the month of a date value.- Returns:
- the new DBColumnExpr object
-
day
Creates and returns an function object that calculates the day of a date value.- Returns:
- the new DBColumnExpr object
-
sum
Creates and returns an aggregation function object which calculates the sum for the current expression over a group of rows.- Returns:
- the new DBFuncExpr object
-
min
Creates and returns an aggregation function object which returns the minimum value for the current expression over a group of rows.- Returns:
- the new DBFuncExpr object
-
max
Creates and returns an aggregation function object which returns the maximum value for the current expression over a group of rows.- Returns:
- the new DBFuncExpr object
-
avg
Creates and returns an aggregation function object which returns the average value for the current expression over a group of rows.- Returns:
- the new DBFuncExpr object
-
stringAgg
Creates and returns string aggregation expression- Parameters:
separator- the separator between stringorderBy- the order by expression- Returns:
- the new DBFuncExpr object
-
stringAgg
Creates and returns string aggregation expression- Parameters:
separator- the separator between string- Returns:
- the new DBFuncExpr object
-
count
Creates and returns an expression for the SQL "count()" function which returns the number of rows in the result set.- Returns:
- the new DBFuncExpr object
-
countDistinct
Creates and returns an expression for the SQL "count()" function which returns the number of unique values in the result set.- Returns:
- the new DBFuncExpr object
-
decodeEnum
Creates and returns a sql-expression that maps enum values by name or ordinal to their string representation- Parameters:
enumType- an enumType to decodeotherwise- the varchar value to take if no key matches the given expression- Returns:
- a DBDecodeExpr object
-
decodeSort
Creates and returns a sql-expression that maps enum values from name to ordinal This is useful for sorting. e.g. cmd.orderBy(SOME_EXPR.decodeSort(MyEnum.class, true)- Parameters:
enumType- an enumType to decodedefaultToEnd- true if non matching values (e.g. NULL) should be assigned the highest number, otherwise they get the lowest number- Returns:
- a DBDecodeExpr object
-
decode
Creates and returns a sql-expression that compares the current column expression with a list of values and returns the corresponding alternative value.- Parameters:
valueMap- a list of key values pairs used for decodingotherwise- the value to take if no key matches the given expression- Returns:
- a DBDecodeExpr object
-
decode
-
decode
-
decode
-
decode
-
decode
-
when
Creates and returns a sql-expression for the SQL case-phrase.
The result will be in the form:
"case when [compExpr] then [this] else [otherwise] end"- Parameters:
compExpr- the condition for which the current column expression is returnedotherwise- the value that is returned if the condition is false- Returns:
- a DBCaseExpr representing the SQL case phrase.
-
convertTo
Creates a new DBFuncExpr object that will convert the current column to the destination data type specified.- Parameters:
dataType- the destination data typeformat- optional destination format (usually a string)- Returns:
- the new DBFuncExpr object
-
convertTo
Creates and returns a new DBFuncExpr object that will convert the current column to the destination data type specified.- Parameters:
dataType- Data type to which to convert the current expression to.- Returns:
- the new DBFuncExpr object
-
toChar
Creates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ")"- Returns:
- the new DBFuncExpr object
-
toChar
Creates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ", * '"+format+"')"- Parameters:
format- the string value- Returns:
- the new DBFuncExpr object
-
function
Creates and returns a function from an sql template The template may consist of the following placeholders: ? = the expression on which the function is applied (usually a column expression) {[param-index]:[DataType]} = a function parameter. The DataType name, if supplied, must match the name of a DataType enum value.- Parameters:
template- the sql phrase template (see above)returnType- the returned DataTypeparams- the list of function parameter values- Returns:
- the function expression
-
aggregate
Creates and returns a function from an sql template The template may consist of the following placeholders: ? = the expression on which the function is applied (usually a column expression) {[param-index]:[DataType]} = a function parameter. The DataType name, if supplied, must match the name of a DataType enum value.- Parameters:
template- the sql phrase template (see above)returnType- the returned DataTypeparams- additional function parameters- Returns:
- the aggregate expression
-
asc
creates a new DBOrderByExpr for ascending order- Returns:
- the new DBOrderByExpr object for ascending order
-
desc
creates a new DBOrderByExpr for descending order- Returns:
- the new DBOrderByExpr object for descending order
-
on
create a join expression for DBCommand.join()- Parameters:
joinWith- the column expression to join this expression with- Returns:
- the join expression
-
getJavaType
returns a corresponding Java type for this expression- Returns:
- the java type
-
toString
For Debugging -
isLiteralValue
Checks if a value is a literal value- Parameters:
value- the value to check- Returns:
- true if the value is a simple value like String, Number, Boolean etc.
-