Class PreparedStatementSQLDialect

    • Constructor Detail

      • PreparedStatementSQLDialect

        protected PreparedStatementSQLDialect​(JDBCDataStore dataStore)
    • Method Detail

      • prepareGeometryValue

        public void prepareGeometryValue​(Class<? extends Geometry> gClass,
                                         int dimension,
                                         int srid,
                                         Class binding,
                                         StringBuffer sql)
        Prepares the geometry value for a prepared statement.

        This method should be overridden if the implementation needs to wrap the geometry placeholder in the function. The default implementationg just appends the default placeholder: '?'.

        Parameters:
        gClass - The geometry class.
        srid - The spatial reference system of the geometry, or -1 if unknown
        dimension - The dimensions (2,3,4) of the coordinates, or -1 if unknown
        binding - The class of the geometry.
        sql - The prepared sql statement buffer.
      • prepareGeometryValue

        public final void prepareGeometryValue​(Geometry g,
                                               int dimension,
                                               int srid,
                                               Class binding,
                                               StringBuffer sql)
        Prepares the geometry value for a prepared statement.

        This method should be overridden if the implementation needs to wrap the geometry placeholder in the function. The default implementationg just appends the default placeholder: '?'.

        Parameters:
        g - The geometry value.
        srid - The spatial reference system of the geometry, or -1 if unknown
        dimension - The dimensions (2,3,4) of the coordinates, or -1 if unknown
        binding - The class of the geometry.
        sql - The prepared sql statement buffer.
      • prepareFunctionArgument

        public void prepareFunctionArgument​(Class clazz,
                                            StringBuffer sql)
        Prepares a function argument for a prepared statement.
        Parameters:
        clazz - The mapped class of the argument.
        sql - The prepared sql statement buffer
      • setGeometryValue

        public abstract void setGeometryValue​(Geometry g,
                                              int dimension,
                                              int srid,
                                              Class binding,
                                              PreparedStatement ps,
                                              int column)
                                       throws SQLException
        Sets the geometry value into the prepared statement.
        Parameters:
        g - The geometry
        srid - the geometry native srid (should be forced into the encoded geometry)
        binding - the geometry type
        ps - the prepared statement
        column - the column index where the geometry is to be set
        Throws:
        SQLException
      • setValue

        public void setValue​(Object value,
                             Class binding,
                             PreparedStatement ps,
                             int column,
                             Connection cx)
                      throws SQLException
        Sets a value in a prepared statement, for "basic types" (non-geometry).

        Subclasses should override this method if they need to do something custom or they wish to support non-standard types.

        Parameters:
        value - the value.
        binding - The class of the value.
        ps - The prepared statement.
        column - The column the value maps to.
        cx - The database connection.
        Throws:
        SQLException
      • setArrayValue

        public void setArrayValue​(Object value,
                                  AttributeDescriptor att,
                                  PreparedStatement ps,
                                  int i,
                                  Connection cx)
                           throws SQLException
        Sets a value in a prepared statement, for the specific case of Array

        This method uses the standard SQL Array handling, subclasses can override to add special behavior

        Parameters:
        value - the value.
        att - The full attribute description
        ps - The prepared statement.
        i - The column the value maps to.
        cx - The database connection.
        Throws:
        SQLException
      • convertToArray

        protected Array convertToArray​(Object value,
                                       String componentTypeName,
                                       Class componentType,
                                       Connection connection)
                                throws SQLException
        Converts a given array value into a Array
        Parameters:
        value - The non null value to be converted
        componentType - The attribute binding (of array type)
        connection - The connection used to create an Array
        Returns:
        The converted array
        Throws:
        SQLException
      • convertArrayElement

        protected Object convertArrayElement​(Object value,
                                             Class<?> target)
                                      throws SQLException
        Converts a given array element to the desired type, throws an exception in case conversion failed
        Parameters:
        value - The value to be converted. Must be non null.
        target - The target class
        Returns:
        The converted value
        Throws:
        SQLException - In case the conversion failed.
      • convert

        protected <T> T convert​(Object value,
                                Class<T> binding)
      • onSelect

        public void onSelect​(PreparedStatement select,
                             Connection cx,
                             SimpleFeatureType featureType)
                      throws SQLException
        Callback invoked before a SELECT statement is executed against the database.

        The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

        Parameters:
        select - The select statement being executed
        cx - The database connection
        featureType - The feature type the select is executing against.
        Throws:
        SQLException
      • onDelete

        public void onDelete​(PreparedStatement delete,
                             Connection cx,
                             SimpleFeatureType featureType)
                      throws SQLException
        Callback invoked before a DELETE statement is executed against the database.

        The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

        Parameters:
        delete - The delete statement being executed
        cx - The database connection
        featureType - The feature type the delete is executing against.
        Throws:
        SQLException
      • onInsert

        public void onInsert​(PreparedStatement insert,
                             Connection cx,
                             SimpleFeatureType featureType)
                      throws SQLException
        Callback invoked before an INSERT statement is executed against the database.

        The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

        Parameters:
        insert - The delete statement being executed
        cx - The database connection
        featureType - The feature type the insert is executing against.
        Throws:
        SQLException
      • onUpdate

        public void onUpdate​(PreparedStatement update,
                             Connection cx,
                             SimpleFeatureType featureType)
                      throws SQLException
        Callback invoked before an UPDATE statement is executed against the database.

        The callback is provided with both the statement being executed and the database connection. Neither should be closed. Any statements created from the connection however in this method should be closed.

        Parameters:
        update - The delete statement being executed
        cx - The database connection
        featureType - The feature type the update is executing against.
        Throws:
        SQLException