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 Type
    Method
    Description
    void
    Clears the current SQL query being built.
    void
    clearSql(boolean keepCurrentBoundParams)
    Clears the current SQL query being built.
    getSql(boolean friendly)
    Returns the current SQL query.
    void
    setBoolean(String paramName, Boolean value)
     
    void
    setDate(String paramName, LocalDate date)
     
    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 <codeIN(:ids)</code section
    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 <codeIN(:ids)</code section
    void
    setInstant(String string, Instant instant)
    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
    void
    setString(String paramName, String value)
     
    void
    sql(String sql)
    Appends some SQL to the query to launch.
  • Method Details

    • sql

      void sql(String sql)
      Appends some SQL to the query to launch. If you want to restart the query from scratch, you need to call clearSql() 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 - if true, the currently bound parameters won't be cleared, only the query.
    • getSql

      String getSql(boolean friendly)
      Returns the current SQL query.
    • setInstant

      void setInstant(String string, Instant instant)
      This replaces setTimestamp()!
    • setDate

      void setDate(String paramName, LocalDate date)
    • setBoolean

      void setBoolean(String paramName, Boolean value)
    • setString

      void setString(String paramName, String value)
    • setInteger

      void setInteger(String paramName, Integer value)
    • setLong

      void setLong(String paramName, Long value)
    • setFloat

      void setFloat(String paramName, Float value)
    • setDouble

      void setDouble(String paramName, Double value)
    • setInLong

      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 <codeIN(:ids)</code section
    • setInInteger

      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 <codeIN(:ids)</code section
    • setInString

      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.
    • setInStringFromEnumNames

      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.
    • setInStringFromEnumNames

      void setInStringFromEnumNames(String paramName, Enum<?>... enumItems)
      Uses a list of enum names so it can be used inside a IN(:ids) section.
    • setLongList

      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

      This allows to retrieve a list of rows, using ids, *in the order the ids are specified*.