public class SQL extends SqlEngineLabels
Modifier and Type | Class and Description |
---|---|
static class |
SQL.config
The Class config.
|
static class |
SQL.DATATYPE
The Enum DATATYPE.
|
static class |
SQL.FORMAT
The Class FORMAT.
|
static class |
SQL.INDEXTYPE
The Enum INDEXTYPE.
|
static class |
SQL.LANG
The Class LANG.
|
static class |
SQL.Punctuation
The Class Punctuation.
|
static class |
SQL.util
The Class util.
|
Modifier and Type | Field and Description |
---|---|
static SqlExpression |
CURRENT_CATALOG
The Constant CURRENT_CATALOG.
|
static SqlExpression |
CURRENT_SCHEMA
The Constant CURRENT_SCHEMA.
|
static SqlExpression |
CURRENT_TIME
The Constant CURRENT_TIME.
|
static SqlExpression |
CURRENT_TIMESTAMP
The Constant CURRENT_TIMESTAMP.
|
static SqlExpression |
CURRENT_USER
The Constant CURRENT_USER.
|
static SqlExpression |
FALSE
The Constant FALSE.
|
static SqlExpression |
NULL
The Constant NULL.
|
static SqlExpression |
STAR
The Constant STAR.
|
static SqlExpression |
TRUE
The Constant TRUE.
|
LABEL_1Param, LABEL_2Param, LABEL_3Param, LABEL_NOTNULL, LABEL_SQL_util_guessAlias, LABEL_UNIQUE
Constructor and Description |
---|
SQL() |
Modifier and Type | Method and Description |
---|---|
static SqlFunctionABS |
ABS(Object value)
ABS.
|
static ColumnValueAssignment |
assign(SqlColumn column,
Object value) |
static SqlAggregateAVG |
AVG(Object value)
AVG.
|
static <R> CALL<R> |
CALL(Class<R> returnType,
PROCEDURE<R> storedProcedure,
Object... paramters) |
static <R> CALL<R> |
CALL(PROCEDURE<R> storedProcedure,
Object... paramters) |
static SqlFunctionCASE |
CASE_WHEN(Object whenExpression,
Object thenExpression,
Object elseExpression)
Resembles an "if"/then/else in SQL.
|
static SqlFunctionCASE |
CASE(Object expression)
Resembles a "switch" in SQL.
|
static SqlColumn |
col(String s)
Col.
|
static SqlAggregateCOLLECT |
COLLECT(Object expression)
COLLECT.
|
static SqlConcatenation |
concatenate(Object... characterValueExpressions)
Concatenate.
|
static SqlCondition |
condition(Object expression)
Wraps the given expression object as an
SqlCondition instance.If the object itself is already a SqlCondition , it is returned right away. |
static boolean |
connect(ConnectionProvider<?> connectionProvider)
Connect.
|
static SqlAggregateCOUNT |
COUNT()
COUNT.
|
static SqlAggregateCOUNT |
COUNT(Object value)
COUNT.
|
static <T extends SqlTable> |
create(Class<T> tableClass,
String alias)
Creates the.
|
static ColumnValueTuple |
cv(SqlColumn column,
Object value) |
static DISTINCT |
DISTINCT(Object expression) |
static DoubleQuotedExpression |
doubleQuote(Object characterValueExpression)
Double quote.
|
static ResultSet |
executeQuery(String query)
Execute query.
|
static Object |
executeQuerySingle(String query)
Execute query single.
|
static int |
executeUpdate(String query)
Execute update.
|
static SqlConditionEXISTS |
EXISTS(SELECT subSelect)
EXISTS.
|
static SqlExpression |
exp(Object o)
Exp.
|
static SqlAggregateFUSION |
FUSION(Object expression)
FUSION.
|
static DatabaseGateway<?> |
getDefaultDatabaseGateway()
Gets the default database gateway.
|
static DbmsAdaptor<?> |
getDefaultDBMS()
Gets the default dbms.
|
static DbmsDMLAssembler<?> |
getDefaultDMLAssembler() |
static QueryListeners |
getGlobalQueryListeners() |
static QueryListeners |
globalQueryListeners() |
static <T extends SqlDdlTable> |
initializeFor(DatabaseGateway<?> dbc,
Class<T> tableClass,
String alias)
Initialize for.
|
static <T extends SqlDdlTable> |
initializeInDb(Class<T> tableClass,
String alias)
Initialize in db.
|
static SqlAggregateINTERSECTION |
INTERSECTION(Object expression)
INTERSECTION.
|
static SqlAggregateMAX |
MAX(Object value)
MAX.
|
static SqlAggregateMin |
MIN(Object value)
MIN.
|
static SqlConditionNOT |
NOT(SqlCondition condition)
NOT.
|
static SqlBooleanTerm |
par(Object expression)
Wraps the given expression object as an
SqlBooleanTerm instance that encloses it in parenthesis
(round brackets).Note that in contradiction to condition(Object) , a new wrapper instance is always created to
ensure that each call actually adds a pair of parenthesis (for whatever reason that might be needed). |
static QuotedExpression |
quote(Object characterValueExpression)
Quote.
|
static SqlxFunctionROUND |
ROUND(Object value,
int decimals)
ROUND.
|
static int |
save(UPDATE update,
Object... parameters)
Executes
update with parameters . |
static SELECT |
SELECT(Object... items)
SELECT.
|
static void |
setDefaultDatabaseGateway(DatabaseGateway<?> defaultDatabaseGateway)
Sets the default database gateway.
|
static void |
setDefaultDBMS(DbmsAdaptor<?> defaultDBMS)
Sets the default dbms.
|
static void |
setGlobalQueryListeners(QueryListeners queryListeners) |
static SqlFunctionSUBSTRING |
SUBSTRING(Object characterValueExpression,
Integer startPosition)
SUBSTRING.
|
static SqlFunctionSUBSTRING |
SUBSTRING(Object characterValueExpression,
Integer startPosition,
Integer stringLength)
SUBSTRING.
|
static SqlFunctionSUBSTRING |
SUBSTRING(Object characterValueExpression,
Integer startPosition,
Integer stringLength,
Integer charLengthUnits)
SUBSTRING.
|
static SqlAggregateSUM |
SUM(Object value)
SUM.
|
static SqlTableIdentity |
TABLE(String tablename)
TABLE.
|
static SqlTableIdentity |
TABLE(String tablename,
String alias)
TABLE.
|
static SqlTableIdentity |
TABLE(String schema,
String tablename,
String alias)
TABLE.
|
static SqlTimestamp |
timestamp(int... parts)
Timestamp.
|
static SqlxFunctionTO_CHAR |
TO_CHAR(Object value,
Object format)
T o_ char.
|
static SqlxFunctionTO_NUMBER |
TO_NUMBER(Object value)
T o_ number.
|
static SqlxAggregateCOLLECT_asString |
xCOLLECT_asString(Object expression)
xCollect_asString.
|
static SqlxAggregateCOLLECT_asString |
xCOLLECT_asString(Object expression,
String seperator)
xCollect_asString.
|
public static final SqlExpression NULL
public static final SqlExpression STAR
public static final SqlExpression TRUE
public static final SqlExpression FALSE
public static final SqlExpression CURRENT_CATALOG
public static final SqlExpression CURRENT_SCHEMA
public static final SqlExpression CURRENT_TIME
public static final SqlExpression CURRENT_TIMESTAMP
public static final SqlExpression CURRENT_USER
public static QueryListeners getGlobalQueryListeners()
public static QueryListeners globalQueryListeners()
public static void setGlobalQueryListeners(QueryListeners queryListeners) throws NullPointerException
queryListeners
- NullPointerException
public static DbmsAdaptor<?> getDefaultDBMS()
public static DbmsDMLAssembler<?> getDefaultDMLAssembler()
public static DatabaseGateway<?> getDefaultDatabaseGateway()
public static void setDefaultDBMS(DbmsAdaptor<?> defaultDBMS)
defaultDBMS
- the defaultDBMS to setpublic static void setDefaultDatabaseGateway(DatabaseGateway<?> defaultDatabaseGateway)
defaultDatabaseGateway
- the defaultDatabaseGateway to setpublic static ResultSet executeQuery(String query) throws SQLEngineException
query
- the querySQLEngineException
- the sQL engine exceptionpublic static Object executeQuerySingle(String query) throws SQLEngineException
query
- the querySQLEngineException
- the sQL engine exceptionpublic static int executeUpdate(String query) throws SQLEngineException
query
- the querySQLEngineException
- the sQL engine exceptionpublic static final SqlTableIdentity TABLE(String tablename)
tablename
- the tablenamepublic static final SqlTableIdentity TABLE(String tablename, String alias)
tablename
- the tablenamealias
- the aliaspublic static final SqlTableIdentity TABLE(String schema, String tablename, String alias)
schema
- the schematablename
- the tablenamealias
- the aliaspublic static final SELECT SELECT(Object... items)
items
- the itemspublic static final <R> CALL<R> CALL(Class<R> returnType, PROCEDURE<R> storedProcedure, Object... paramters)
public static ColumnValueTuple cv(SqlColumn column, Object value)
public static ColumnValueAssignment assign(SqlColumn column, Object value)
public static final SqlFunctionABS ABS(Object value)
value
- the valuepublic static final SqlAggregateSUM SUM(Object value)
value
- the valuepublic static final SqlAggregateMAX MAX(Object value)
value
- the valuepublic static final SqlAggregateMin MIN(Object value)
value
- the valuepublic static final SqlAggregateAVG AVG(Object value)
value
- the valuepublic static final SqlAggregateCOUNT COUNT()
public static final SqlAggregateCOUNT COUNT(Object value)
value
- the valuepublic static final SqlAggregateCOLLECT COLLECT(Object expression)
expression
- the expressionpublic static final SqlxAggregateCOLLECT_asString xCOLLECT_asString(Object expression)
expression
- the expressionpublic static final SqlxAggregateCOLLECT_asString xCOLLECT_asString(Object expression, String seperator)
expression
- the expressionseperator
- the seperatorpublic static final SqlAggregateFUSION FUSION(Object expression)
expression
- the expressionpublic static final SqlAggregateINTERSECTION INTERSECTION(Object expression)
expression
- the expressionpublic static final SqlConcatenation concatenate(Object... characterValueExpressions)
characterValueExpressions
- the character value expressionspublic static final SqlFunctionCASE CASE_WHEN(Object whenExpression, Object thenExpression, Object elseExpression)
whenExpression
- the when expressionthenExpression
- the then expressionelseExpression
- the else expressionSQL.CASE} for the "switch" equivalent
public static final SqlFunctionCASE CASE(Object expression)
expression
- the expressionSQL.CASE_WHEN} for the "if"/then/else equivalent
public static final SqlFunctionSUBSTRING SUBSTRING(Object characterValueExpression, Integer startPosition, Integer stringLength, Integer charLengthUnits)
characterValueExpression
- the character value expressionstartPosition
- the start positionstringLength
- the string lengthcharLengthUnits
- the char length unitspublic static final SqlFunctionSUBSTRING SUBSTRING(Object characterValueExpression, Integer startPosition, Integer stringLength)
characterValueExpression
- the character value expressionstartPosition
- the start positionstringLength
- the string lengthpublic static final SqlFunctionSUBSTRING SUBSTRING(Object characterValueExpression, Integer startPosition)
characterValueExpression
- the character value expressionstartPosition
- the start positionpublic static final SqlConditionNOT NOT(SqlCondition condition)
condition
- the conditionpublic static final SqlConditionEXISTS EXISTS(SELECT subSelect)
subSelect
- the sub selectpublic static final SqlxFunctionTO_NUMBER TO_NUMBER(Object value)
value
- the valuepublic static final SqlxFunctionTO_CHAR TO_CHAR(Object value, Object format)
value
- the valueformat
- the formatpublic static final SqlxFunctionROUND ROUND(Object value, int decimals)
value
- the valuedecimals
- the decimalspublic static QuotedExpression quote(Object characterValueExpression)
characterValueExpression
- the character value expressionpublic static DoubleQuotedExpression doubleQuote(Object characterValueExpression)
characterValueExpression
- the character value expressionpublic static final SqlBooleanTerm par(Object expression)
SqlBooleanTerm
instance that encloses it in parenthesis
(round brackets).condition(Object)
, a new wrapper instance is always created to
ensure that each call actually adds a pair of parenthesis (for whatever reason that might be needed).expression
- the expression to be wrapped as SqlBooleanTerm
SqlBooleanTerm
instance wrapping the passed expression object.public static final SqlCondition condition(Object expression)
SqlCondition
instance.SqlCondition
, it is returned right away.expression
- the expression to be wrapped as SqlCondition
SqlCondition
instance representing the passed expression object's content as a condition.public static final SqlExpression exp(Object o)
o
- the opublic static final SqlTimestamp timestamp(int... parts)
parts
- the partspublic static boolean connect(ConnectionProvider<?> connectionProvider) throws SQLEngineCouldNotConnectToDBException
connectionProvider
- the connection providerSQLEngineCouldNotConnectToDBException
- the sQL engine could not connect to db exceptionpublic static <T extends SqlTable> T create(Class<T> tableClass, String alias) throws SQLEngineRuntimeException
T
- the generic typetableClass
- the table classalias
- the aliasSQLEngineRuntimeException
- the sQL engine runtime exceptionpublic static <T extends SqlDdlTable> T initializeInDb(Class<T> tableClass, String alias) throws SQLEngineRuntimeException
T
- the generic typetableClass
- the table classalias
- the aliasSQLEngineRuntimeException
- the sQL engine runtime exceptionpublic static <T extends SqlDdlTable> T initializeFor(DatabaseGateway<?> dbc, Class<T> tableClass, String alias) throws SQLEngineRuntimeException
T
- the generic typedbc
- the dbctableClass
- the table classalias
- the aliasSQLEngineRuntimeException
- the sQL engine runtime exceptionpublic static int save(UPDATE update, Object... parameters)
update
with parameters
.
If 0 rows have been affected by the UPDATE, then an INSERT with the
same column-value assignment and target table is derived from the UPDATE and executed.
A save is meant to update or insert values for a single row of data automatically as needed.
Still it is possible, to update multiple rows via call of this method, if the conditions in update
are set in the right way (or "wrong" way, if you intended to only update one row.)
If the UPDATE already affects rows, the performance of this method is the same as calling
UPDATE.execute()
directly. Only if an INSERT is really needed additional work is done.
update
- parameters
- Copyright © 2003–2021 XDEV Software. All rights reserved.