public abstract class SqlStatement extends Object
SqlStatement
is used to generate SQL Statements. Prepare the generated Statements and also to parse
the resultSetsModifier and Type | Class and Description |
---|---|
static class |
SqlStatement.Condition
Construct the condition statement that will be used in the where clause
|
static class |
SqlStatement.Delete
SQL Statement generator for DELETE Statements
|
static class |
SqlStatement.Insert
INSERT Statement generator
|
static class |
SqlStatement.ResultSetReader
ResultSetReader is used to parse the result set and gives methods for getting appropriate type of
data given the column name |
static class |
SqlStatement.Select
Select Statement generator.
|
static class |
SqlStatement.Update
UPDATE SQL Statement generator
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
forUpdate |
protected StringBuilder |
sb |
protected List<Object> |
values |
Constructor and Description |
---|
SqlStatement() |
Modifier and Type | Method and Description |
---|---|
static SqlStatement.Condition |
and(SqlStatement.Condition... conds)
Logical AND condition Generator
|
static SqlStatement.Condition |
between(Schema.Column column,
Object lVal,
Object rVal)
BETWEEN range checking statement
|
static SqlStatement.Delete |
deleteFrom(Schema.Table table)
Return a new Delete Statement
|
static SqlStatement.Select |
getCount(Schema.Table... tables)
Select count(*) Statement generator.
|
SqlStatement |
getNewStatementWithValues(Map<Object,Object> newValues)
Replace the keys(newValues) which are place holders in the sql statements with the corresponding new values.
|
static SqlStatement.Condition |
greaterThan(Schema.Column column,
Object value)
Generate Condition statement for GREATER THAN condition checking
|
static SqlStatement.Condition |
greaterThanOrEqual(Schema.Column column,
Object value)
Generate Condition statement for GREATER THAN OR EQUAL condition checking
|
static SqlStatement.Condition |
in(Schema.Column column,
Object... values)
IN Condition for checking multiple values
|
static SqlStatement.Condition |
in(Schema.Column column,
SqlStatement.Select select)
Sub query with IN condition
|
static SqlStatement.Insert |
insertInto(Schema.Table table)
Return a new Insert Statement
|
static SqlStatement.Condition |
isEqual(Schema.Column column,
Object value)
Generate Condition statement for equality check
|
static SqlStatement.Condition |
isLike(Schema.Column column,
String value)
Generate condition statement for IS LIKE
|
static SqlStatement.Condition |
isNotEqual(Schema.Column column,
Object value)
Generate InEquality Condition statement
|
static SqlStatement.Condition |
isNotLike(Schema.Column column,
String value)
Generates condition statement for IS NOT LIKE
|
static SqlStatement.Condition |
isNotNull(Schema.Column column)
Generate condition statement for IS NOT NULL
|
static SqlStatement.Condition |
isNull(Schema.Column column)
Generate condition statement for IS NULL
|
static SqlStatement.Condition |
lessThan(Schema.Column column,
Object value)
Generate Condition statement for LESS THAN condition checking
|
static SqlStatement.Condition |
lessThanOrEqual(Schema.Column column,
Object value)
Generate Condition statement for LESS THAN OR EQUAL condition checking
|
static SqlStatement.Condition |
notBetween(Schema.Column column,
Object lVal,
Object rVal)
NOT BETWEEN range checking statement
|
static SqlStatement.Condition |
notIn(Schema.Column column,
Object... values)
NOT IN Condition for checking multiple values
|
static SqlStatement.Condition |
notIn(Schema.Column column,
SqlStatement.Select select)
Sub query with NOT IN condition
|
static SqlStatement.Condition |
or(SqlStatement.Condition... conds)
Logical OR condition generator
|
static SqlStatement.ResultSetReader |
parse(ResultSet rSet)
Create the
ResultSetReader object that has the methods to access the data from the result set |
PreparedStatement |
prepare(Connection conn)
Prepare the SQL Statement.
|
PreparedStatement |
prepare(PreparedStatement pStmt)
Assign the values to Prepared Statement.
|
PreparedStatement |
prepareAndSetValues(Connection conn)
Prepare the SQL Statement that is generated and assign the values to prepared statement.
|
PreparedStatement |
prepareForBatch(Connection conn,
List<? extends Map<Object,Object>> values,
PreparedStatement pStmt)
Preparing Multiple statements for batch execution.
|
static SqlStatement.Select |
selectAllFrom(Schema.Table... tables)
Return a Select All Statement
|
static SqlStatement.Select |
selectColumns(Schema.Column... columns)
Return a Select Statement
|
SqlStatement |
setValue(Object oldVal,
Object newVal)
Replace the place holders with actual values in the sql statement
|
static SqlStatement.Update |
update(Schema.Table table)
Return a new Update Statement
|
protected boolean forUpdate
protected StringBuilder sb
public SqlStatement()
public static SqlStatement.Condition isNull(Schema.Column column)
column
- column namepublic static SqlStatement.Condition isNotNull(Schema.Column column)
column
- column namepublic static SqlStatement.Condition isLike(Schema.Column column, String value)
column
- column namevalue
- value to be checkedpublic static SqlStatement.Condition isNotLike(Schema.Column column, String value)
column
- column namevalue
- value to be checkedpublic static SqlStatement.Condition isEqual(Schema.Column column, Object value)
column
- the columnvalue
- the valuepublic static SqlStatement.Condition isNotEqual(Schema.Column column, Object value)
column
- the columnvalue
- the valuepublic static SqlStatement.Condition lessThan(Schema.Column column, Object value)
column
- the columnvalue
- the valuepublic static SqlStatement.Condition greaterThan(Schema.Column column, Object value)
column
- the columnvalue
- the valuepublic static SqlStatement.Condition lessThanOrEqual(Schema.Column column, Object value)
column
- the columnvalue
- the valuepublic static SqlStatement.Condition greaterThanOrEqual(Schema.Column column, Object value)
column
- the columnvalue
- the valuepublic static SqlStatement.Condition in(Schema.Column column, Object... values)
column
- the columnvalues
- the valuespublic static SqlStatement.Condition notIn(Schema.Column column, Object... values)
column
- the columnvalues
- the valuespublic static SqlStatement.Condition in(Schema.Column column, SqlStatement.Select select)
column
- the columnselect
- the sub querypublic static SqlStatement.Condition notIn(Schema.Column column, SqlStatement.Select select)
column
- the columnselect
- the sub querypublic static SqlStatement.Condition between(Schema.Column column, Object lVal, Object rVal)
column
- the columnlVal
- min value for range checkingrVal
- max value for range checkingpublic static SqlStatement.Condition notBetween(Schema.Column column, Object lVal, Object rVal)
column
- the columnlVal
- min value for range checkingrVal
- max value for range checkingpublic static SqlStatement.Condition and(SqlStatement.Condition... conds)
conds
- list of conditions for ANDpublic static SqlStatement.Condition or(SqlStatement.Condition... conds)
conds
- list of conditions for ORpublic PreparedStatement prepareAndSetValues(Connection conn) throws SQLException
conn
- ConnectionSQLException
- in case of errorpublic PreparedStatement prepare(PreparedStatement pStmt) throws SQLException
pStmt
- Prepared StatementSQLException
- in case of errorpublic PreparedStatement prepare(Connection conn) throws SQLException
conn
- ConnectionSQLException
- in case of errorpublic PreparedStatement prepareForBatch(Connection conn, List<? extends Map<Object,Object>> values, PreparedStatement pStmt) throws SQLException
conn
- Connectionvalues
- A list of maps that contains the actual valuesSQLException
- in case of errorpublic SqlStatement setValue(Object oldVal, Object newVal)
oldVal
- Place holdernewVal
- Actual Valuepublic SqlStatement getNewStatementWithValues(Map<Object,Object> newValues)
newValues
- the new valuespublic static SqlStatement.ResultSetReader parse(ResultSet rSet)
ResultSetReader
object that has the methods to access the data from the result setrSet
- Result Setpublic static SqlStatement.Insert insertInto(Schema.Table table)
table
- the target tablepublic static SqlStatement.Update update(Schema.Table table)
table
- the target tablepublic static SqlStatement.Delete deleteFrom(Schema.Table table)
table
- the target tablepublic static SqlStatement.Select selectAllFrom(Schema.Table... tables)
tables
- the target tablespublic static SqlStatement.Select selectColumns(Schema.Column... columns)
columns
- columns to selectpublic static SqlStatement.Select getCount(Schema.Table... tables)
tables
- the target tableCopyright © 2018 Apache Software Foundation. All rights reserved.