Class BasicSQLDialect

Object
SQLDialect
BasicSQLDialect
Direct Known Subclasses:
DB2SQLDialectBasic, DuckDBDialect, H2DialectBasic, H2GISDialect, InformixDialect, MySQLDialectBasic, PostGISDialect, SingleStoreDialectBasic, SQLServerDialect

public abstract class BasicSQLDialect extends SQLDialect
  • Constructor Details

    • BasicSQLDialect

      protected BasicSQLDialect(JDBCDataStore dataStore)
  • Method Details

    • encodeValue

      public void encodeValue(Object value, Class type, StringBuffer sql)
      Encodes a value in an sql statement.

      Subclasses may wish to override or extend this method to handle specific types. This default implementation does the following:

      1. The value is encoded via its Object.toString() representation.
      2. If type is a character type (extends CharSequence), it is wrapped in single quotes (').
    • encodeGeometryValue

      public abstract void encodeGeometryValue(Geometry value, int dimension, int srid, StringBuffer sql) throws IOException
      Encodes a geometry value in an sql statement.

      An implementations should serialize value into some exchange format which will then be transported to the underlying database. For example, consider an implementation which converts a geometry into its well known text representation:

         
         sql.append( "GeomFromText('" );
         sql.append( new WKTWriter().write( value ) );
         sql.append( ")" );
         
        

      The srid parameter is the spatial reference system identifier of the geometry, or 0 if not known.

      Attention should be paid to emtpy geometries (g.isEmtpy() == true) as they cannot be encoded in WKB and several databases fail to handle them property. Common treatment is to equate them to NULL

      Throws:
      IOException
    • createFilterToSQL

      public FilterToSQL createFilterToSQL()
      Creates the filter encoder to be used by the datastore when encoding query predicates.

      Sublcasses can override this method to return a subclass of FilterToSQL if need be.

    • onSelect

      public void onSelect(Statement 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(Statement 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(Statement 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(Statement 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