org.springframework.jdbc.core

Class PreparedStatementCreatorFactory

  • java.lang.Object
    • org.springframework.jdbc.core.PreparedStatementCreatorFactory


  • public class PreparedStatementCreatorFactory
    extends java.lang.Object
    Helper class that efficiently creates multiple PreparedStatementCreator objects with different parameters based on a SQL statement and a single set of parameter declarations.
    Author:
    Rod Johnson, Thomas Risberg, Juergen Hoeller
    • Constructor Detail

      • PreparedStatementCreatorFactory

        public PreparedStatementCreatorFactory(java.lang.String sql)
        Create a new factory. Will need to add parameters via the addParameter(org.springframework.jdbc.core.SqlParameter) method or have no parameters.
        Parameters:
        sql - the SQL statement to execute
      • PreparedStatementCreatorFactory

        public PreparedStatementCreatorFactory(java.lang.String sql,
                                               int... types)
        Create a new factory with the given SQL and JDBC types.
        Parameters:
        sql - the SQL statement to execute
        types - int array of JDBC types
      • PreparedStatementCreatorFactory

        public PreparedStatementCreatorFactory(java.lang.String sql,
                                               java.util.List<SqlParameter> declaredParameters)
        Create a new factory with the given SQL and parameters.
        Parameters:
        sql - the SQL statement to execute
        declaredParameters - list of SqlParameter objects
    • Method Detail

      • addParameter

        public void addParameter(SqlParameter param)
        Add a new declared parameter.

        Order of parameter addition is significant.

        Parameters:
        param - the parameter to add to the list of declared parameters
      • setResultSetType

        public void setResultSetType(int resultSetType)
        Set whether to use prepared statements that return a specific type of ResultSet.
        Parameters:
        resultSetType - the ResultSet type
        See Also:
        ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE
      • setUpdatableResults

        public void setUpdatableResults(boolean updatableResults)
        Set whether to use prepared statements capable of returning updatable ResultSets.
      • setReturnGeneratedKeys

        public void setReturnGeneratedKeys(boolean returnGeneratedKeys)
        Set whether prepared statements should be capable of returning auto-generated keys.
      • setGeneratedKeysColumnNames

        public void setGeneratedKeysColumnNames(java.lang.String... names)
        Set the column names of the auto-generated keys.
      • newPreparedStatementSetter

        public PreparedStatementSetter newPreparedStatementSetter(@Nullable
                                                                  java.util.List<?> params)
        Return a new PreparedStatementSetter for the given parameters.
        Parameters:
        params - list of parameters (may be null)
      • newPreparedStatementSetter

        public PreparedStatementSetter newPreparedStatementSetter(@Nullable
                                                                  java.lang.Object[] params)
        Return a new PreparedStatementSetter for the given parameters.
        Parameters:
        params - the parameter array (may be null)
      • newPreparedStatementCreator

        public PreparedStatementCreator newPreparedStatementCreator(@Nullable
                                                                    java.util.List<?> params)
        Return a new PreparedStatementCreator for the given parameters.
        Parameters:
        params - list of parameters (may be null)
      • newPreparedStatementCreator

        public PreparedStatementCreator newPreparedStatementCreator(@Nullable
                                                                    java.lang.Object[] params)
        Return a new PreparedStatementCreator for the given parameters.
        Parameters:
        params - the parameter array (may be null)
      • newPreparedStatementCreator

        public PreparedStatementCreator newPreparedStatementCreator(java.lang.String sqlToUse,
                                                                    @Nullable
                                                                    java.lang.Object[] params)
        Return a new PreparedStatementCreator for the given parameters.
        Parameters:
        sqlToUse - the actual SQL statement to use (if different from the factory's, for example because of named parameter expanding)
        params - the parameter array (may be null)