Interface Statement
- All Known Subinterfaces:
BatchInsertStatement,DeleteStatement,InsertStatement,SelectStatement,UpdateStatement
- All Known Implementing Classes:
BatchInsertStatementDefault,DeleteStatementDefault,InsertStatementDefault,SelectStatementDefault,StatementBase,UpdateStatementDefault
public interface Statement
Note that the connection used by a Stement is
not closed after the statement has
been executed.
Have a look at JdbcScope to manage the
closing of connections properly.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclearSql()Clears the current SQL query being built.voidclearSql(boolean keepCurrentBoundParams) Clears the current SQL query being built.getSql(boolean friendly) Returns the current SQL query.voidsetBoolean(String paramName, Boolean value) voidvoidvoidvoidsetInInteger(String paramName, Set<Integer> items) Explodes a collection of Integer and replaces the specified param with them, so it can be used inside a <codeIN(:ids)</code sectionvoidExplodes a collection of Long and replaces the specified param with them, so it can be used inside a <codeIN(:ids)</code sectionvoidsetInstant(String string, Instant instant) This replaces setTimestamp()!voidsetInString(String paramName, Set<String> items) Explodes a collection of String and replaces the specified param with them, so it can be used inside aIN(:ids)section.voidsetInStringFromEnumNames(String paramName, Enum<?>... enumItems) Uses a list of enum names so it can be used inside aIN(:ids)section.voidsetInStringFromEnumNames(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 aIN(:ids)section.voidsetInteger(String paramName, Integer value) voidvoidsetLongList(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.idvoidvoidAppends some SQL to the query to launch.
-
Method Details
-
sql
Appends some SQL to the query to launch. If you want to restart the query from scratch, you need to callclearSql()first! -
clearSql
void clearSql()Clears the current SQL query being built. Also removes any bound parameters. -
clearSql
void clearSql(boolean keepCurrentBoundParams) Clears the current SQL query being built.- Parameters:
keepCurrentBoundParams- iftrue, the currently bound parameters won't be cleared, only the query.
-
getSql
Returns the current SQL query. -
setInstant
This replaces setTimestamp()! -
setDate
-
setBoolean
-
setString
-
setInteger
-
setLong
-
setFloat
-
setDouble
-
setInLong
Explodes a collection of Long and replaces the specified param with them, so it can be used inside a <codeIN(:ids)</code section -
setInInteger
Explodes a collection of Integer and replaces the specified param with them, so it can be used inside a <codeIN(:ids)</code section -
setInString
Explodes a collection of String and replaces the specified param with them, so it can be used inside aIN(:ids)section. -
setInStringFromEnumNames
Explodes a collection of enum names and replaces the specified param with them, so it can be used inside aIN(:ids)section. -
setInStringFromEnumNames
Uses a list of enum names so it can be used inside aIN(:ids)section. -
setLongList
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.idThis allows to retrieve a list of rows, using ids, *in the order the ids are specified*.
-