Package com.im.commons.db.dml
Class SQLElementFactory
- java.lang.Object
-
- com.im.commons.db.dml.SQLElementFactory
-
- All Implemented Interfaces:
java.io.Serializable
public final class SQLElementFactory extends java.lang.Object implements java.io.Serializable
- Author:
- Tim Dudgeon
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SQLElementFactory(DBDatabaseInfo dbInfo)
SQLElementFactory(TermEncoder encoder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SQLWhereClauseCompositeElement
createAndClause()
static SQLWhereClauseCompositeElement
createAndClause(SQLJoin join)
static SQLWhereClauseCompositeElement
createOrClause()
static SQLWhereClauseCompositeElement
createOrClause(SQLJoin join)
SQLOrderByClause
createOrderByClause(SortColumn[] sortCols)
SQLSelectColumn
createSelectColumn(TableDefinition table, java.lang.String column, int jdbcType, SQLJoin join)
SQLSelectFunction
createSelectFunction(TableDefinition table, java.lang.String functionSql, java.lang.String alias)
SQLSelectStatement
createSelectStatement()
TableColumn
createTableColumn(TableDefinition table, java.lang.String column, int jdbcType)
SQLWhereClauseElement
createWhereClauseFreeformElement(TableDefinition table, java.lang.String freeformWhereFragment)
SQLWhereClauseElement
createWhereClauseInListElement(TableColumn tableColumn, java.lang.Object[] values)
Create an in list where clause of type:
WHERE col IN (1,2,3...)
.SQLWhereClauseElement
createWhereClauseInListElement(TableColumn tableColumn, java.util.Collection values)
Create an in list where clause of type:
WHERE col IN (1,2,3...)
.SQLWhereClauseElement
createWhereClauseNotInListElement(TableColumn tableColumn, java.lang.Object[] values)
Create an in list where clause of type:
WHERE col NOT IN (1,2,3...)
.SQLWhereClauseElement
createWhereClauseNotInListElement(TableColumn tableColumn, java.util.Collection values)
Create an in list where clause of type:
WHERE col NOT IN (1,2,3...)
.SQLWhereClauseElement
createWhereClauseTermElement(TableColumn tableColumn, SQLWhereClauseTermElement.SQL_OPERATORS operator)
SQLWhereClauseElement
createWhereClauseTermElement(TableColumn tableColumn, SQLWhereClauseTermElement.SQL_OPERATORS operator, int placeholders)
SQLWhereClauseElement
createWhereClauseTermElement(TableColumn tableColumn, SQLWhereClauseTermElement.SQL_OPERATORS operator, java.util.List<?> values)
SQLWhereClauseElement
createWhereClauseTermElement(TableColumn tableColumn1, TableColumn tableColumn2, SQLWhereClauseTermElement.SQL_OPERATORS operator)
SQLSelectStatement
sqlSelectDistinct(TableDefinition table, java.lang.String[] columnNames)
SQLSelectStatement
sqlSelectInList(java.util.List<SQLSelectElement> selectElements, TableColumn inClauseColumn, java.util.Collection<?> idValues)
Creates a SQL SELECT statement in the formSELECT foo, bar FROM baz WHERE idClauseColumn IN (idValues)
.SQLSelectStatement
sqlSelectPS(java.util.List<SQLSelectElement> selectElements, TableColumn whereTermColumn)
Creates SQL for aPreparedStatement
in the formSELECT foo, bar FROM baz WHERE whereTermColumn = ?
.SQLSelectStatement
sqlSelectPSmore(java.util.List<SQLSelectElement> selectElements, java.util.List<TableColumn> whereTermColumns)
Creates SQL for aPreparedStatement
in the formSELECT foo, bar FROM baz WHERE whereTermColumn1 = ? AND ... AND whereTermColumnN = ?
.
-
-
-
Constructor Detail
-
SQLElementFactory
public SQLElementFactory(DBDatabaseInfo dbInfo)
-
SQLElementFactory
public SQLElementFactory(TermEncoder encoder)
-
-
Method Detail
-
createOrderByClause
public SQLOrderByClause createOrderByClause(SortColumn[] sortCols)
-
createAndClause
public static SQLWhereClauseCompositeElement createAndClause()
-
createOrClause
public static SQLWhereClauseCompositeElement createOrClause()
-
createAndClause
public static SQLWhereClauseCompositeElement createAndClause(SQLJoin join)
-
createOrClause
public static SQLWhereClauseCompositeElement createOrClause(SQLJoin join)
-
createSelectStatement
public SQLSelectStatement createSelectStatement()
-
createSelectFunction
public SQLSelectFunction createSelectFunction(TableDefinition table, java.lang.String functionSql, java.lang.String alias)
-
createSelectColumn
public SQLSelectColumn createSelectColumn(TableDefinition table, java.lang.String column, int jdbcType, SQLJoin join)
-
createTableColumn
public TableColumn createTableColumn(TableDefinition table, java.lang.String column, int jdbcType)
-
createWhereClauseTermElement
public SQLWhereClauseElement createWhereClauseTermElement(TableColumn tableColumn, SQLWhereClauseTermElement.SQL_OPERATORS operator, java.util.List<?> values)
-
createWhereClauseTermElement
public SQLWhereClauseElement createWhereClauseTermElement(TableColumn tableColumn, SQLWhereClauseTermElement.SQL_OPERATORS operator, int placeholders)
-
createWhereClauseTermElement
public SQLWhereClauseElement createWhereClauseTermElement(TableColumn tableColumn, SQLWhereClauseTermElement.SQL_OPERATORS operator)
-
createWhereClauseTermElement
public SQLWhereClauseElement createWhereClauseTermElement(TableColumn tableColumn1, TableColumn tableColumn2, SQLWhereClauseTermElement.SQL_OPERATORS operator)
-
createWhereClauseInListElement
public SQLWhereClauseElement createWhereClauseInListElement(TableColumn tableColumn, java.util.Collection values)
Create an in list where clause of type:
WHERE col IN (1,2,3...)
.- Parameters:
tableColumn
- The column namevalues
- A list of values for the list- Returns:
- The SQLInClause
-
createWhereClauseInListElement
public SQLWhereClauseElement createWhereClauseInListElement(TableColumn tableColumn, java.lang.Object[] values)
Create an in list where clause of type:
WHERE col IN (1,2,3...)
.- Parameters:
tableColumn
- The column namevalues
- An array of values for the list- Returns:
- The SQLInClause
-
createWhereClauseNotInListElement
public SQLWhereClauseElement createWhereClauseNotInListElement(TableColumn tableColumn, java.util.Collection values)
Create an in list where clause of type:
WHERE col NOT IN (1,2,3...)
.- Parameters:
tableColumn
- The column namevalues
- A list of values for the list- Returns:
- The SQLInClause
-
createWhereClauseNotInListElement
public SQLWhereClauseElement createWhereClauseNotInListElement(TableColumn tableColumn, java.lang.Object[] values)
Create an in list where clause of type:
WHERE col NOT IN (1,2,3...)
.- Parameters:
tableColumn
- The column namevalues
- An array of values for the list- Returns:
- The SQLInClause
-
sqlSelectInList
public SQLSelectStatement sqlSelectInList(java.util.List<SQLSelectElement> selectElements, TableColumn inClauseColumn, java.util.Collection<?> idValues)
Creates a SQL SELECT statement in the formSELECT foo, bar FROM baz WHERE idClauseColumn IN (idValues)
.- Parameters:
selectElements
- The elements that the SELECT statement will return as a result.inClauseColumn
- The column for the WHERE clause term constraint.idValues
- The values constraining theinClauseColumn
.- Returns:
- A
SQLSelectStatement
suitable for creating a SQL SELECT string.
-
sqlSelectPS
public SQLSelectStatement sqlSelectPS(java.util.List<SQLSelectElement> selectElements, TableColumn whereTermColumn)
Creates SQL for aPreparedStatement
in the formSELECT foo, bar FROM baz WHERE whereTermColumn = ?
. AllselectElements
andwhereTermColumn
have to refer to the sameTableDefinition
.- Parameters:
selectElements
- The elements that the SELECT statement will return as a result.whereTermColumn
- The column for the WHERE clause term constraint.- Returns:
- A
SQLSelectStatement
suitable for creating aPreparedStatement
.
-
sqlSelectPSmore
public SQLSelectStatement sqlSelectPSmore(java.util.List<SQLSelectElement> selectElements, java.util.List<TableColumn> whereTermColumns)
Creates SQL for aPreparedStatement
in the formSELECT foo, bar FROM baz WHERE whereTermColumn1 = ? AND ... AND whereTermColumnN = ?
. AllselectElements
andwhereTermColumns
have to refer to the sameTableDefinition
.- Parameters:
selectElements
- The elements that the SELECT statement will return as a result.whereTermColumns
- The columns for the WHERE clause term constraints.- Returns:
- A
SQLSelectStatement
suitable for creating aPreparedStatement
.
-
sqlSelectDistinct
public SQLSelectStatement sqlSelectDistinct(TableDefinition table, java.lang.String[] columnNames)
-
createWhereClauseFreeformElement
public SQLWhereClauseElement createWhereClauseFreeformElement(TableDefinition table, java.lang.String freeformWhereFragment)
-
-