Announcement Announcement Module
No announcement yet.
SimpleJdbcInsert on table with PostGIS two geometries Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleJdbcInsert on table with PostGIS two geometries

    I have a table with two geometry columns and cannot seem to use SimpleJdbcInsert to insert some geometry info.
    [2009-10-29 11:03:13,269] [TableMetaDataProvider] [DEBUG] GetGeneratedKeys is supported
    [2009-10-29 11:03:13,270] [TableMetaDataProvider] [DEBUG] GeneratedKeysColumnNameArray is supported for PostgreSQL
    [2009-10-29 11:03:13,272] [TableMetaDataProvider] [DEBUG] Retrieving metadata for null/public/test
    [2009-10-29 11:03:13,277] [TableMetaDataProvider] [DEBUG] Retrieved metadata: id 4 false
    [2009-10-29 11:03:13,279] [TableMetaDataProvider] [DEBUG] Retrieved metadata: geom 1111 true

    I've been so far as to hardcode the type mapping to geometries by manually generating the SqlParameterSource that gets sent to executeAndReturnKey() with:

    incomingMap.addValue("geom", "ST_GeomFromText('POLYGON...', 4326)", 1111);

    But I keep getting a parse error:
    [DEBUG] PreparedStatementCallback; uncategorized SQLException for SQL []; SQL state [XX000]; error code [0]; ERROR: parse error - invalid geometry
    Hint: You must specify a valid OGC WKT geometry type such as POINT, LINESTRING or POLYGON

    I doublechecked the WKT and it looks fine. Before I try the PostGIS crowd, I wanted to see if anyone has tried this. Hopefully I don't have to abandon the investment into SimpleJdbcInsert just for this.

    The Postgres log does show Spring doing some investigation on the geometry types so it's doing something with it at least.
    Last edited by lighthousej; Oct 29th, 2009, 10:30 AM.

  • #2

    I ended up doing this:

    incomingMap.addValue("geom", "SRID=4326;POLYGON(...)", 1111);

    You have depend on Pg to cast that string to a geometry via a proper method.