public abstract class StatementBase extends Object implements Statement
Connection.getAutoCommit() is true/code>,
the connection will be automatically closed. If you want to prevent this,
you can use the disableCloseConnection parameter... You
can then reuse the connection, but it's up to you to close it when you're
done.
Some code based on :
| Constructor and Description |
|---|
StatementBase(Connection connection) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addCurrentParamsToStatement(PreparedStatement statement) |
void |
addParam(String paramName,
Object value) |
protected void |
addParamsToStatement(PreparedStatement statement,
Map<String,Object> params) |
protected void |
clearParams() |
void |
clearSql()
Clears the current SQL query being built.
|
void |
clearSql(boolean keepCurrentBoundParams)
Clears the current SQL query being built.
|
protected void |
close(PreparedStatement statement)
Closes statement quietly
|
protected void |
close(ResultSet resultSet)
Closes resultSet quietly
|
protected void |
copyParamsAndStaticTokensTo(Statement newStm) |
protected Connection |
getConnection() |
protected Map<String,Set<Integer>> |
getIndexMap() |
protected String |
getOriginalQuery() |
protected Map<String,Object> |
getParams() |
protected String |
getParsedQuery() |
protected StringBuilder |
getQueryBuilder() |
String |
getSql(boolean friendly)
Returns the current SQL query.
|
protected BasicFormatterImpl |
getSqlFormmatter() |
protected Map<String,String> |
getStaticTokens() |
protected String |
parse() |
void |
setBoolean(String paramName,
Boolean value) |
void |
setDate(String paramName,
LocalDate value) |
void |
setDouble(String paramName,
Double value) |
void |
setFloat(String paramName,
Float value) |
void |
setInInteger(String paramName,
Set<Integer> items)
Explodes a collection of Integer and replaces the specified param with them,
so it can be used inside a
|
void |
setInLong(String paramName,
Set<Long> items)
Explodes a collection of Long and replaces the specified param with them,
so it can be used inside a
|
void |
setInstant(String paramName,
Instant value)
This replaces setTimestamp()!
|
void |
setInString(String paramName,
Set<String> items)
Explodes a collection of String and replaces the specified param with them,
so it can be used inside a
IN(:ids) section. |
void |
setInStringFromEnumNames(String paramName,
Enum<?>... enumItems)
Uses a list of enum names so it can be used inside a
IN(:ids) section. |
void |
setInStringFromEnumNames(String paramName,
Set<? extends Enum<?>> enumItems)
Explodes a collection of enum names and replaces the specified param with them,
so it can be used inside a
IN(:ids) section. |
void |
setInteger(String paramName,
Integer value) |
void |
setLong(String paramName,
Long value) |
void |
setLongList(String paramName,
List<Long> items)
Explodes a list of Long and replaces the specified param with them,
so it can be used to replace a "ids list" inside a (PostgreSQL example):
INNER JOIN UNNEST('{:idsList}'::int[]) WITH ORDINALITY o(id, ord) ON o.id = myMainTable.id |
protected void |
setParams(Map<String,Object> params) |
protected void |
setStaticTokens(Map<String,String> tokens) |
void |
setString(String paramName,
String value) |
void |
sql(String sql)
Appends some SQL to the query to launch.
|
String |
toString() |
public StatementBase(Connection connection)
protected StringBuilder getQueryBuilder()
protected BasicFormatterImpl getSqlFormmatter()
public void sql(String sql)
StatementStatement.clearSql() first!public void clearSql()
Statementpublic void clearSql(boolean keepCurrentBoundParams)
Statementpublic String getSql(boolean friendly)
Statementprotected String getOriginalQuery()
protected String getParsedQuery()
protected void copyParamsAndStaticTokensTo(Statement newStm)
protected String parse()
protected void clearParams()
protected Connection getConnection()
protected void addCurrentParamsToStatement(PreparedStatement statement)
protected void addParamsToStatement(PreparedStatement statement, Map<String,Object> params)
protected void close(PreparedStatement statement)
protected void close(ResultSet resultSet)
public void setInstant(String paramName, Instant value)
StatementsetInstant in interface Statementpublic void setBoolean(String paramName, Boolean value)
setBoolean in interface Statementpublic void setInteger(String paramName, Integer value)
setInteger in interface Statementpublic void setInLong(String paramName, Set<Long> items)
Statementpublic void setInInteger(String paramName, Set<Integer> items)
StatementsetInInteger in interface Statementpublic void setInString(String paramName, Set<String> items)
StatementIN(:ids) section.setInString in interface Statementpublic void setInStringFromEnumNames(String paramName, Set<? extends Enum<?>> enumItems)
StatementIN(:ids) section.setInStringFromEnumNames in interface Statementpublic void setInStringFromEnumNames(String paramName, Enum<?>... enumItems)
StatementIN(:ids) section.setInStringFromEnumNames in interface Statementpublic void setLongList(String paramName, List<Long> items)
StatementINNER JOIN UNNEST('{:idsList}'::int[]) WITH ORDINALITY o(id, ord) ON o.id = myMainTable.id
This allows to retrieve a list of rows, using ids, *in the order the ids are specified*.
setLongList in interface StatementCopyright © 2019. All rights reserved.