Skip navigation links
org.spincast.plugins.jdbc.statements

Class StatementBase

    • Constructor Detail

      • StatementBase

        public StatementBase(Connection connection)
    • Method Detail

      • sql

        public void sql(String sql)
        Description copied from interface: Statement
        Appends some SQL to the query to launch. If you want to restart the query from scratch, you need to call Statement.clearSql() first!
        Specified by:
        sql in interface Statement
      • clearSql

        public void clearSql()
        Description copied from interface: Statement
        Clears the current SQL query being built. Also removes any bound parameters.
        Specified by:
        clearSql in interface Statement
      • clearSql

        public void clearSql(boolean keepCurrentBoundParams)
        Description copied from interface: Statement
        Clears the current SQL query being built.
        Specified by:
        clearSql in interface Statement
        Parameters:
        keepCurrentBoundParams - if true, the currently bound parameters won't be cleared, only the query.
      • getSql

        public String getSql(boolean friendly)
        Description copied from interface: Statement
        Returns the current SQL query.
        Specified by:
        getSql in interface Statement
      • getOriginalQuery

        protected String getOriginalQuery()
      • getParsedQuery

        protected String getParsedQuery()
      • setStaticTokens

        protected void setStaticTokens(Map<String,String> tokens)
      • copyParamsAndStaticTokensTo

        protected void copyParamsAndStaticTokensTo(Statement newStm)
      • parse

        protected String parse()
      • clearParams

        protected void clearParams()
      • getConnection

        protected Connection getConnection()
      • addCurrentParamsToStatement

        protected void addCurrentParamsToStatement(PreparedStatement statement)
      • close

        protected void close(PreparedStatement statement)
        Closes statement quietly
      • close

        protected void close(ResultSet resultSet)
        Closes resultSet quietly
      • addParam

        public void addParam(String paramName,
                             Object value)
      • setInLong

        public void setInLong(String paramName,
                              Set<Long> items)
        Description copied from interface: Statement
        Explodes a collection of Long and replaces the specified param with them, so it can be used inside a
        Specified by:
        setInLong in interface Statement
      • setInInteger

        public void setInInteger(String paramName,
                                 Set<Integer> items)
        Description copied from interface: Statement
        Explodes a collection of Integer and replaces the specified param with them, so it can be used inside a
        Specified by:
        setInInteger in interface Statement
      • setInString

        public void setInString(String paramName,
                                Set<String> items)
        Description copied from interface: Statement
        Explodes a collection of String and replaces the specified param with them, so it can be used inside a IN(:ids) section.
        Specified by:
        setInString in interface Statement
      • setInStringFromEnumNames

        public void setInStringFromEnumNames(String paramName,
                                             Set<? extends Enum<?>> enumItems)
        Description copied from interface: Statement
        Explodes a collection of enum names and replaces the specified param with them, so it can be used inside a IN(:ids) section.
        Specified by:
        setInStringFromEnumNames in interface Statement
      • setInStringFromEnumNames

        public void setInStringFromEnumNames(String paramName,
                                             Enum<?>... enumItems)
        Description copied from interface: Statement
        Uses a list of enum names so it can be used inside a IN(:ids) section.
        Specified by:
        setInStringFromEnumNames in interface Statement
      • setLongList

        public void setLongList(String paramName,
                                List<Long> items)
        Description copied from interface: Statement
        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*.

        Specified by:
        setLongList in interface Statement

Copyright © 2019. All rights reserved.